您的位置:首页 > 其它

ListView添加HeaderView后,HeaderView里的控件设置某些属性不起作用

2016-05-12 16:34 337 查看


当我们为listview,add一个headerView时,headerview里有好多控件,例如:
<RelativeLayout
android:id="@+id/rl_apply_content"
android:layout_width="match_parent"
android:layout_height="350dp"
android:background="@drawable/live_apply">

<ImageView
android:id="@+id/shader"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_alignParentBottom="true"
android:background="@drawable/video_bottom_height448" />

<ImageView
android:id="@+id/iv_apply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignTop="@+id/shader"
android:layout_centerHorizontal="true"
android:src="@drawable/apply" />
</RelativeLayout>第二个ImageView如果设置marginBottom,会不起作用,此时我们要把布局改成下面这样:
<?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">

<RelativeLayout
android:id="@+id/rl_apply_content"
android:layout_width="match_parent"
android:layout_height="350dp"
android:background="@drawable/live_apply">

<ImageView
android:id="@+id/shader"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_alignParentBottom="true"
android:background="@drawable/video_bottom_height448" />

<ImageView
android:id="@+id/iv_apply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignTop="@+id/shader"
android:layout_centerHorizontal="true"
android:src="@drawable/apply" />
</RelativeLayout>

</RelativeLayout>搞定
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息