我有一個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有趣的鏈接,謝謝。我想我可能會根據該信息的線索來處理解決方案。 –