Yanshof
Yanshof

Reputation: 9926

How to control the linearLayout size when define new linearLayout in runtime ?

I need to create X numbers of linearLayout - that each linearLayout contain Text( item name ), Bitmap ( item bitmap image ).

So, i make some for loop that create dynamically linearLayout and '.addView' to out in the linearLayout the text and the Bitmap.

the problem is that the text of each item is with different text size ==> this make my UI look not good.

How can i define that the text size will be same in all the linearLayout and make the UI look good ?

Upvotes: 1

Views: 160

Answers (1)

Gopal Nair
Gopal Nair

Reputation: 840

You can compute the largest text length, and use setWidth() method of text view object to set the width during runtime.

Alternatively, you should look into ellipsize property of text view, to put a "..." in large texts at the end. Here is the URL to ellipsize documentation: http://developer.android.com/reference/android/widget/TextView.html#attr_android:ellipsize

Upvotes: 1

Related Questions