我希望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可以显示的值,否则为什么会需要省略号。它非常简单。 (除非你知道) –