I have this XML here, and I want to set the max_width for the linear layout to 600dp or something. Why doesn’t Android allow this?
EDIT: The question is WHY, not how. E.g., why would the Android team decide to have it like this?
<LinearLayout
android:id="@+id/details_type_info_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
¿¿¿android:max_width = "600dp"???
android:background="@color/light_grey"
android:orientation="vertical" >
<TextView
android:id="@+id/details_type_info_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="15dp"
android:text="@string/placeholder" />
<TextView
android:id="@+id/details_text_info_source"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:text="@string/details_source"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="italic" />
</LinearLayout>
To answer your question, I guess it was just a design
oversightdecision from the Android team.Glad you found a solution. Another approach would be to stick it inside another container with an absolute width set. Why 600dp, though? If the screen’s got more room, limiting it to a hard value has a high potential to look weird.