我有一个TextView从'0'开始,并更新按钮按下以反映当前总得分public int points
。 TextView会更新,但乐谱中的一个或多个字符会被截断(例如,“1580”可能会显示为“158”或“15”)。但是,当活动完成并发送到记分牌活动时,所显示的点是正确的(变量传递的意图是相同的变量points
)。动态设置TextView与String.valueOf(intVar)截断intVar的一部分
这里是我相关的Java代码:
public int points = 0;
TextView currentScoreCounter = (TextView) findViewById(R.id.scoreCounter);
currentScoreCounter.setText(String.valueOf(points));
这里是我的XML文件中的scoreCounter
:
<TextView
android:id="@+id/scoreCounter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textSize="30dp"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true" />
我怀疑它可能有一些做的宽度/高度TextView,但我不确定。
你可以尝试[自动缩放TextView以适合范围内](https://stackoverflow.com/questions/5033012/auto-scale-textview-text-to-fit-within-bounds) –
是否运行到任何UI的其他部分? –
@DavidRawson有趣的链接,谢谢。我想我可能会根据该信息的线索来处理解决方案。 –