I’m trying to have a layout in a certain width, using the layout_width property, but when inflated – the width of the layout is taken from the child, which is smaller then the layout_width I stated. Here’s an example:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/blabla"
android:orientation="vertical"
android:layout_width="310dip"
android:layout_height="fill_parent"
>
<TextView android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="60dip"
android:paddingTop="15dip"
android:paddingLeft="23dip"
android:text="udini "
/>
</LinearLayout>
This code make the entire layout be in the width of 60dip.
But when adding the minWidth attribute to the layout, with the value 310dip, then the width of the layout is as expected.
Why is it like that? Is the layout_width attribute just a suggestion?
Thanks,
Udi
LinearLayouts are not required to honour thelayout_widthattribute when it’s not set towrap_contentorfill_parent.You can still use
android:minWidthif that’s enough for you, or other options are using theandroid:layout_weightattribute or increase theandroid:paddingattribute on the child.