Will <include> override layout_width / layout_height?

I have a layout XML file named my_layout.xml with the root view layout_width and layout_height specified as 200px.

<com.jlee.demo.MyLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="horizontal"
     android:layout_width="200px"
     android:layout_height="200px">

      

If i used this xml to be included in another xml and set layout_width and layout_height as 100px.

<include layout="@layout/my_layout"
     android:layout_width="100px"
     android:layout_height="100px"/>

      

What would be the real width / height of my_layout?

+2


a source to share


2 answers


The answer to the top voter on this question should help you:

Does Android XML tag "include" tag actually work?



you can only override parameters that start with layout_. so in your case the layout should be 100 * 100.

+6


a source


Overriding android: layout_below doesn't seem to work

If you want to override any layout_ * attributes with a tag, both layout_width and layout_height must be overridden.



See the last lines of the include section at http://developer.android.com/training/improving-layouts/reusing-layouts.html#Include

+3


a source







All Articles