mrd
mrd

Reputation: 4699

Android: How can I force a layout or any view to have a fixed size in dip?

Is it possible to force a layout to have a fixed size in dip?

Either a View directly or using a layout forced to have a fixed size in dip and put the view inside the layout?

And how?

Upvotes: 3

Views: 5307

Answers (2)

Rahmathullah M
Rahmathullah M

Reputation: 2716

You can set specific width to the Layout you want using

android:layout_width="100dp"

You can do it in both way. directly to the View as well as put the View inside a Layout

Upvotes: 3

Chandra Sekhar
Chandra Sekhar

Reputation: 19492

Yes its possible, You just need to declare the required height and width of the view or layout in xml file as below

android:layout_width="200dip" <!--use this instead of wrap_content or fill_parent-->
android:layout_height="200dip"

Upvotes: 2

Related Questions