RecycleView单元格填满屏幕

用户名

我正在关注有关android编程的教程,并且遇到了recycleviews的麻烦。每个视图的单元格似乎都占据了整个屏幕空间,而不仅仅是单元格中的信息。如图所示:

在此处输入图片说明

activity_fragment.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.example.moore.criminalintent.CrimeActivity">


    <include layout="@layout/content_fragment" />


</android.support.design.widget.CoordinatorLayout>

content_fragment.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="com.example.moore.criminalintent.CrimeActivity"
    tools:showIn="@layout/activity_fragment">

    <FrameLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/fragment_container"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"></FrameLayout>
</RelativeLayout>

fragment_crime.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/Crime_title_label"
        style="?android:listSeparatorTextViewStyle"/>
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/crime_title"
        android:hint="@string/crime_title_hint"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/crime_detail_label"
        style="?android:listSeparatorTextViewStyle"/>
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/crime_date"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"/>
    <CheckBox
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/crime_solved"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"
        android:text="@string/crime_solved_label"/>
</LinearLayout>

fragment_crime_list.xml

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.v7.widget.RecyclerView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/crime_recycler_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

list_item_crime.xml

<?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:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <CheckBox
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/list_item_crime_solved_check_box"
        android:layout_alignParentRight="true"
        android:padding="4dp"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/list_item_crime_title_text_view"
        android:layout_toLeftOf="@id/list_item_crime_solved_check_box"
        android:textStyle="bold"
        android:padding="4dp"
        tools:text="Crime Title"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/list_item_crime_date_text_view"
        android:layout_toLeftOf="@id/list_item_crime_solved_check_box"
        android:layout_below="@id/list_item_crime_title_text_view"
        android:padding="4dp"
        tools:text="Crime Date"/>

</RelativeLayout>

如果需要,我可以发布更多代码。任何有关如何解决此问题的帮助将不胜感激。

萨加尔·乔加迪亚(Sagar Jogadia)

试试这个:

list_item_crime.xml

<?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:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <CheckBox
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/list_item_crime_solved_check_box"
        android:layout_alignParentRight="true"
        android:padding="4dp"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/list_item_crime_title_text_view"
        android:layout_toLeftOf="@id/list_item_crime_solved_check_box"
        android:textStyle="bold"
        android:padding="4dp"
        tools:text="Crime Title"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/list_item_crime_date_text_view"
        android:layout_toLeftOf="@id/list_item_crime_solved_check_box"
        android:layout_below="@id/list_item_crime_title_text_view"
        android:padding="4dp"
        tools:text="Crime Date"/>

</RelativeLayout>

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

kivy filechooserlistview没有填满屏幕

来自分类Dev

对话框未填满屏幕

来自分类Dev

React标题没有填满屏幕

来自分类Dev

kivy filechooserlistview没有填满屏幕

来自分类Dev

如何用视频填满屏幕?

来自分类Dev

LinearLayout 和 CameraSource 不填满屏幕

来自分类Dev

Xamarin webview 不填满屏幕

来自分类Dev

使单元格的宽度和高度相同,以填满表格

来自分类Dev

使用公式自动填充单元格范围。填满而不是填满

来自分类Dev

当大对象填满屏幕时,暂停打印

来自分类Dev

缩放圆圈的大小正好足以填满屏幕

来自分类Dev

导航栏不会完全填满屏幕宽度

来自分类Dev

文本小部件将填满屏幕的一半

来自分类Dev

Bootstrap Vue导航栏未填满屏幕

来自分类Dev

RecyclerView项目宽度未填满屏幕宽度

来自分类Dev

缩放圆圈的大小刚好足以填满屏幕

来自分类Dev

文本小部件将填满屏幕的一半

来自分类Dev

textView和按钮不会填满屏幕

来自分类Dev

Android ScrollView旋转后未填满屏幕的整个宽度

来自分类Dev

如何让 PyQt5 中的小部件填满屏幕?

来自分类Dev

如何使单元格高度适合屏幕

来自分类Dev

屏幕的UITableView单元格大小

来自分类Dev

将 <div> 冻结在屏幕顶部,使剩余的 <div> 填满屏幕并滚动

来自分类Dev

将长行转换为宽行,填满所有单元格

来自分类Dev

Google Script:当单元格填满时,提示询问用户是否要运行脚本

来自分类Dev

单元格移出屏幕后如何停止单元格中的AVPlayer播放

来自分类Dev

如何使布局垂直填满屏幕,但是当内容不合适时开始增长

来自分类Dev

表强制显示:块;响应式设计无法填满屏幕

来自分类Dev

列内的容器内的GridView不会填满屏幕的其余部分

Related 相关文章

热门标签

归档