views:

37

answers:

2

How can I set the TextView properties like width, height using Java Code?

+1  A: 

Here you have all TextView methods:

http://developer.android.com/reference/android/widget/TextView.html

If you read the complete page, then you will become a TextView guru.

Cristian
Thank u so much.. it helped me a lot...
Annjo
txtname.seWidth(100);
Annjo
txtname is TextView name and 100 pixel is width.
Annjo
+1  A: 

In the activity where you inflate the view, you can grab the TextView with

TextView t = (TextView)findViewById(R.id.myTextView);

where myTextView is the id that you declared in your XML.

Now go ahead and t.setText("Something");, t.setWidth(200), ...

espinchi
thank u very much
Annjo