2017-02-16 38 views
-1

我希望textview顯示輸入的多餘字符,並像任何標準計算器應用程序中那樣輸入最新的字符,將剩下的字符推入左邊。 maxLength = 14。當輸入字符時(一次輸入14個字符,如圖所示),它根本不顯示它們。我認爲我做錯了什麼,但無法弄清楚什麼。我已經閱讀了一些類似的錯誤的stackoverflow的其他答案,並嘗試瞭解決方案,但它沒有奏效。爲什麼我不能顯示在textview中輸入的多餘字符?

謝謝:)

下面是TextView的XML代碼: `

<TextView 
      android:id="@+id/full_expression" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_marginLeft="40dp" 
      android:layout_marginRight="40dp" 
      android:layout_weight="1" 
      android:alpha="0.85" 
      android:background="@android:color/transparent" 
      android:elevation="6dp" 
      android:fontFamily="sans-serif" 
      android:gravity="bottom|end" 
      android:maxLength="14" 
      android:maxLines="1" 
      android:paddingEnd="10dp" 
      android:scrollHorizontally="true" 
      android:text="0" 
      android:textColor="@android:color/background_light" 
      android:textSize="34sp" /> 

When I click any other button it doesn't show at all after there are 14 characters already

+0

我終於能夠通過將maxLenght增加到100或更高來簡單地解決這個問題。實際上我認爲超過15的任何價值都可以發揮作用。理由是將maxLength增加到超過textview可以顯示的值,否則爲什麼會需要省略號。它非常簡單。 (除非你知道) –

回答

1

使用 「安卓重力」 屬性來對齊內的TextView文本。

+0

但問題不在於對齊textview內的文本。這個答案似乎是無關緊要的。 –

+0

如果您將對齊方式設置爲Right,那麼它將始終將您的文本顯示在最右邊。 –

+0

我嘗試過,因爲這是在你之前的答案中正是建議。它不起作用。就一件事。當我將重力設置到正確位置時,我應該移除重力:末端和底部? –

相關問題