RelativeLayout+include产生的问题


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:orientation="vertical"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content">
          <TextView android:id="@+id/textview"
               android:layout_height="wrap_content"
               android:layout_width="wrap_content"/>
</LinearLayout>

<!-- lang: xml -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/layout_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        android:paddingBottom="@dimen/activity_vertical_margin"
        tools:context=".MainActivity"
        android:background="@drawable/splash">
        <include android:id="@+id/sv"
                 layout="@layout/subview"
                 android:layout_height="wrap_content"
                 android:layout_width="wrap_content"
                 android:layout_marginLeft="80dp"/>
        <include android:id="@+id/sv1"
                 android:layout_height="wrap_content"
                 android:layout_width="wrap_content"
                 layout="@layout/subview"
                 android:layout_below="@id/sv"/>

这里在include的时候需要覆盖 android:layout_height和 android:layout_width属性,否则所有其他关于layout的属性设置都会被忽略掉。
参考:http://stackoverflow.com/questions/2316465/how-to-get-relativelayout-working-with-merge-and-include

你可能感兴趣的:(RelativeLayout+include产生的问题)