<include>会覆盖layout_width/layout_height值吗?

Joh*_*nny 5 android

我有一个名为my_layout.xml的布局xml文件,其中根视图的layout_width和layout_height已指定为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">
Run Code Online (Sandbox Code Playgroud)

如果我使用此xml包含在另一个xml中,并将layout_width和layout_height指定为100px.

<include layout="@layout/my_layout"
     android:layout_width="100px"
     android:layout_height="100px"/>
Run Code Online (Sandbox Code Playgroud)

my_layout的实际宽度/高度是多少?

Rof*_*ion 5

这个问题中最高投票的答案可以帮助你:

Android XML Layout的'include'标签真的有用吗?

您只能覆盖以layout_开头的参数.所以在你的情况下,布局应该是100*100.