RelativeLayout直接include另一个layout是会把include中的控件与当前layout中的控件覆盖重叠,经过查资料

其中的include标签一定要加上(因为include中不指定这二个属性其他所有属性都无效)

android:layout_height="wrap_content"       

android:layout_width="match_parent" 

二个属性并指定id属性android:  

再在当前layout的控件中指定属性android:layout_below="@id/head" 代码如下

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"

    tools:context="com.zhouwei.uitest.MainActivity">

    <include layout="@layout/title" android:id="@+id/head"
        android:layout_height="wrap_content"
        android:layout_width="match_parent" ></include>

    <TextView
        android:id="@+id/textView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="Hello World!"
        android:textColor="#FF0000"
    android:layout_below="@id/head"
    android:textSize="50px" />
</RelativeLayout>

 

没加前效果

RelativeLayout中include 控件覆盖重叠的问题


加了后

RelativeLayout中include 控件覆盖重叠的问题


 
                    
            
                

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-08
  • 2021-12-24
  • 2021-07-03
  • 2021-10-15
  • 2021-11-14
  • 2021-12-22
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-22
  • 2021-09-02
  • 2021-10-23
  • 2021-12-04
  • 2021-12-04
相关资源
相似解决方案