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