神仙客

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
<?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设置具体高度,或者取消相对属性设置。
posted on 2016-02-26 10:12  神仙客  阅读(8962)  评论(0编辑  收藏  举报