RelativeLayout 中的 layout_below失效


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/layout_item_bg">

    <LinearLayout
        android:id="@+id/ll_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true">

        <ImageView
            android:id="@+id/iv_tip"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:contentDescription="@null"
            android:src="@drawable/c20160225204107" />


    </LinearLayout>

    <LinearLayout
        android:id="@+id/tx_description"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/ll_title">

        <TextView
            android:id="@+id/tv_description"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="?attr/infoTextColor"
            android:text="测试"/>
    </LinearLayout>
</RelativeLayout>
View Cod
ImageView 和 TextView 重叠,android:layout_below="@id/ll_title" 失效

原因:

在Relativelayout 未设置具体高度的情况下,前者使用相对属性:android:layout_centerInParent="true",后者layout_below
失效。

解决办法:
给Relativelayout设置具体高度,或者取消相对属性设置。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM