Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between android:layout_width and android:width

Tags:

android

layout

I do not know the difference between these two attributes and for the height also.

Take a TextView for example, what would happen if I set its layout_width to wrap_content and set its width to 50 dip?

like image 538
virsir Avatar asked Apr 26 '10 13:04

virsir


2 Answers

There is a difference when using it in combination with layout_weight to fill a parent layout.

When using layout_weight on a TextView you need to set android:width to 0dip. Setting android:layout_width to 0dip will not work.

like image 148
GMBrian Avatar answered Sep 29 '22 16:09

GMBrian


There is essentially no difference, only a TextView has the width property also.

TextView.setWidth

like image 41
Robby Pond Avatar answered Sep 29 '22 15:09

Robby Pond