Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically set width and height of TextView in Android

I am trying to set TextView width dynamically, Using setWidth(width) method.

txtviewOne.setWidth(10);
txtviewTwo.setWidth(10);

But not success.

Please help me How can I set width of textview dynamically.

like image 559
Ranjit Chandel Avatar asked Oct 09 '12 12:10

Ranjit Chandel


1 Answers

TextView tv;
----------------------
tv=new TextView(this);   // or  tv=new TextView(R.id.textview1);

LinearLayout.LayoutParams Params1 = new LinearLayout.LayoutParams(15,50);
tv.setLayoutParams(Params1);  
like image 108
AnilPatel Avatar answered Sep 21 '22 10:09

AnilPatel