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