I have been trying everything to get this to work, but to no avail. I tried to use the (AutoResizeTextView) posted here: Auto Scale TextView Text to Fit within Bounds
I created a new class file in my project with the name "AutoResizeTextView" and pasted the above code.
Then i opened the main.xml file and put n the following code:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <com.mn.rl.AutoResizeTextView android:id="@+id/tv" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </LinearLayout>
in the mainActivity.java file, i have the following code:
package com.mn.rl; import android.app.Activity; import android.os.Bundle; public class rlActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); com.mn.rl.AutoResizeTextView txt = (com.mn.rl.AutoResizeTextView) findViewById(R.id.tv); txt.setText("Hello"); } }
I have no errors in the code, and it runs but there is no autoresizing. the text remains the same size. in the xml i have the autoresize textview layout_width and layout_height set to fill parent, yet the font remains small. also tried txt.resize().
What am i doing wrong? Please Help.