0

I have found a solution to fit text inside a TextView at Auto Scale TextView Text to Fit within Bounds. However, my solution doesn't seem to work.

Here is my xml:

<parkpurdue.parkpurdue.AutoResizeTextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"

    android:text="Park @ Purdue"
    android:layout_weight="1.6"
    android:background="#3366FF"
    android:id="@+id/parkAtPurdue"
    android:singleLine="true"
    android:gravity="center"
    android:textColor="#FFFFFF"
    android:maxLines="1"/>

And here is my java code:

TextView topText = (TextView) findViewById(R.id.parkAtPurdue);
topText.setText("Park at Purdue");

I tried changing the java code to this as well:

AutoResizeTextView topText = new AutoResizeTextView(getApplicationContext());
topText = (AutoResizeTextView) findViewById(R.id.parkAtPurdue);
topText.setText("Park at Purdue");

I tried calling the topText.resize() function as well. No apparent results were found. What am I doing wrong? What do I need to change?

Community
  • 1
  • 1
Aditya
  • 23
  • 4

1 Answers1

0

Try:

AutoResizeTextView topText = (AutoResizeTextView) findViewById(R.id.parkAtPurdue);
topText.setText("Park at Purdue");
Booger
  • 18,579
  • 7
  • 55
  • 72