使用RecyclerView定制列表项

来源:互联网 发布:网络运维管理规范 编辑:程序博客网 时间:2024/05/22 12:18
<?xml version="1.0" encoding="utf-8"?><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">    <CheckBox        android:id="@+id/list_crime_solved_check_box"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_alignParentRight="true"        android:padding="4dp"/>    <TextView        android:id="@+id/list_item_crime_title_text_view"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_toLeftOf="@id/list_crime_solved_check_box"        android:textStyle="bold"        android:padding="4dp"        android:text="Crime Title"/>    <TextView        android:id="@+id/list_item_crime_date_text_view"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_toLeftOf="@id/list_crime_solved_check_box"        android:layout_below="@id/list_item_crime_title_text_view"        android:padding = "4dp"        tools:text="Crime Date"/></RelativeLayout>
RelativeLayout中layout_width和layout_height属性值设置对总终显示效果的影响
若设置为match_parent,则呈现出这样
若设置为wrap_content,则就会显示出想要的效果
搞清楚和谁匹配这个关系还是很重要的。
所以对《android编程权威指南》终第九章定制列表项图9-11中RelativeLayout的属性android:layout_height值应设置为wrap_content.否则出不来书中的效果。
0 0
原创粉丝点击