0

I have a TextView that starts at '0' and is updated on button press to reflect the current score total, public int points. The TextView does update, but one or more of the characters in the score are truncated (for instance, "1580" might display as "158" or "15"). When the activity is completed and sent to the scoreboard activity, however, the points shown are correct (the variable passed on intent is the same variable points).

Here is my relevant Java code:

public int points = 0;

TextView currentScoreCounter = (TextView) findViewById(R.id.scoreCounter);
currentScoreCounter.setText(String.valueOf(points));

And here is the scoreCounter in my XML file:

<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" />

I suspect it may have something to do with the width/height of the TextView, but I am unsure.

Randall Arms Jr.
  • 368
  • 1
  • 3
  • 19

1 Answers1

3

You could use android:layout_weight=".60 to cover say 60% of the width, be sure to set android:layout_width="0dp" from my limited testing, that works, but will always be the same static size.

Tony Kutzler
  • 433
  • 2
  • 11
  • The weight was not being properly resized dynamically, which was cutting off part of the text. Resizing the width manually showed that the TextView's text was indeed being set properly. This is the answer, thank you. – Randall Arms Jr. Aug 17 '17 at 23:01