How to Set the Android TextView Width Property?

 

Android TextView Width property makes the TextView be exactly the parametric pixels wide. It should be done the same thing by mention this size  in the LayoutParams. We can set Android TextView Width property in the following two ways mentioned bellow:

 

Set Android TextView Width in XML Editor:

<TextView
android:id="@+id/exampleTextView"
android:layout_width="fill_parent"


android:layout_height="wrap_content"
android:text="@string/hello"
android:width="100dp" />

 

Set Android TextView Width in Java Code:

super.onCreate(savedInstanceState);
setContentView(R.layout.main);


TextView exampleTextView = (TextView)findViewById(R.id.exampleTextView);
exampleTextView.setWidth(100);


exampleTextView.setText("Hello Android - from Rahinur.com");

 

Android TextView Width XML Attribute:
android:width

 

Android TextView Width method:
setWidth(int width)

 

Please Note:

I have test this attribute(Android TextView Width) on Android SDK Version 15

Expert in Oracle Database 10g and 11g. Deep knowledge on SQL, PL/SQL and Java programming. Working at Square InformatiX Limited as Oracle Database Administrator.

Posted in Android Tagged with:

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>