How can I set the TextView properties like width, height using Java Code?
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)
, ...
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With