Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 视图未采用全宽_Android_Xml - Fatal编程技术网

Android 视图未采用全宽

Android 视图未采用全宽,android,xml,Android,Xml,在我的应用程序中,我使用的是recyclerview。我需要自定义列表数据,因此我制作了一个自定义适配器。现在的问题是,在android studio的预览窗口中,视图似乎是全宽的,但在设备上,视图不是全宽的,因此我的一半数据被剪切 XMl 请告诉我哪里出错了?在父级中使用填充,而不是像下面那样使用边距,并检查ListView的填充和边距,这可能会停止视图的全宽渲染 <RelativeLayout xmlns:android="http://schemas.android.com

在我的应用程序中,我使用的是recyclerview。我需要自定义列表数据,因此我制作了一个自定义适配器。现在的问题是,在android studio的预览窗口中,视图似乎是全宽的,但在设备上,视图不是全宽的,因此我的一半数据被剪切

XMl



请告诉我哪里出错了?

在父级中使用填充,而不是像下面那样使用边距,并检查ListView的填充和边距,这可能会停止视图的全宽渲染

   <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="2dp"
        android:layout_paddingLeft="5dp"
        android:layout_paddingRight="5dp"
        android:layout_marginTop="2dp"
        android:background="#EDEFF1">
       <TextView
        android:id="@+id/tv_g_name"
        style="@style/text_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:padding="10dp"
        android:text="Ashton Kutcher" />

    <ImageView
        android:id="@+id/iv_g_del"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:padding="10dp"
        android:src="@drawable/ic_cancellation" />

    <TextView
        android:id="@+id/textView33"
        android:layout_width="2dp"
        android:layout_height="match_parent"
        android:layout_alignBottom="@+id/tv_g_name"
        android:layout_toLeftOf="@+id/iv_g_del"
        android:layout_toStartOf="@+id/iv_g_del"
        android:background="#D6D7D9" />

    <ImageView
        android:id="@+id/iv_g_add"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_toLeftOf="@+id/textView33"
        android:layout_toStartOf="@+id/textView33"
        android:padding="10dp"
        android:src="@drawable/ic_cancellation" />

    <TextView
        android:id="@+id/textView34"
        android:layout_width="2dp"
        android:layout_height="match_parent"
        android:layout_alignBottom="@+id/textView33"
        android:layout_toLeftOf="@+id/iv_g_add"
        android:layout_toStartOf="@+id/iv_g_add"
        android:background="#D6D7D9" />

    <TextView
        android:id="@+id/textView35"
        android:layout_width="match_parent"
        android:layout_height="2dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/iv_g_add"
        android:background="#D6D7D9" />

    <ImageView
        android:id="@+id/imageView5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignTop="@+id/textView35"
        android:paddingBottom="05dp"
        android:paddingLeft="10dp"
        android:paddingRight="05dp"
        android:paddingTop="05dp"
        android:src="@drawable/ic_cancellation" />

    <TextView
        android:id="@+id/tv_g_email"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/imageView5"
        android:layout_below="@+id/textView35"
        android:layout_toEndOf="@+id/imageView5"
        android:layout_toRightOf="@+id/imageView5"
        android:gravity="center"
        android:text="pavanh.dev@gmail.com" />

    <ImageView
        android:id="@+id/imageView6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/tv_g_email"
        android:layout_toEndOf="@+id/tv_g_email"
        android:layout_toRightOf="@+id/tv_g_email"
        android:paddingBottom="05dp"
        android:paddingLeft="10dp"
        android:paddingRight="05dp"
        android:paddingTop="05dp"
        android:src="@drawable/ic_cancellation" />

    <TextView
        android:id="@+id/tv_g_number"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/imageView6"
        android:layout_below="@+id/textView35"
        android:layout_toEndOf="@+id/imageView6"
        android:layout_toRightOf="@+id/imageView6"
        android:gravity="center"
        android:text="889845412" />
</RelativeLayout>


尝试使用
fill\u parent
而不是
match\u parent

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="2dp"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp"
    android:layout_marginTop="2dp"
    android:background="#EDEFF1">

在第一个文本视图中,您忘记了提到名称空间
android:style
。请纠正这一点。

试试这个

<?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="match_parent"
    android:layout_marginBottom="2dp"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp"
    android:layout_marginTop="2dp"
    android:background="#EDEFF1">


    <TextView
        android:id="@+id/tv_g_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:padding="10dp"
        android:text="Ashton Kutcher" />

    <ImageView
        android:id="@+id/iv_g_del"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:padding="10dp"
        android:src="@drawable/ic_launcher" />

    <TextView
        android:id="@+id/textView33"
        android:layout_width="2dp"
        android:layout_height="match_parent"
        android:layout_alignBottom="@+id/tv_g_name"
        android:layout_toLeftOf="@+id/iv_g_del"
        android:layout_toStartOf="@+id/iv_g_del"
        android:background="#D6D7D9" />

    <ImageView
        android:id="@+id/iv_g_add"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_toLeftOf="@+id/textView33"
        android:layout_toStartOf="@+id/textView33"
        android:padding="10dp"
        android:src="@drawable/ic_launcher" />

    <TextView
        android:id="@+id/textView34"
        android:layout_width="2dp"
        android:layout_height="match_parent"
        android:layout_alignBottom="@+id/textView33"
        android:layout_toLeftOf="@+id/iv_g_add"
        android:layout_toStartOf="@+id/iv_g_add"
        android:background="#D6D7D9" />

    <TextView
        android:id="@+id/textView35"
        android:layout_width="match_parent"
        android:layout_height="2dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/iv_g_add"
        android:background="#D6D7D9" />

    <ImageView
        android:id="@+id/imageView5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignTop="@+id/textView35"
        android:paddingBottom="05dp"
        android:paddingLeft="10dp"
        android:paddingRight="05dp"
        android:paddingTop="05dp"
        android:src="@drawable/ic_launcher" />

    <TextView
        android:id="@+id/tv_g_email"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/imageView5"
        android:layout_below="@+id/textView35"
        android:layout_toEndOf="@+id/imageView5"
        android:layout_toRightOf="@+id/imageView5"
        android:gravity="center"
        android:text="pavanh.dev@gmail.com" />

    <ImageView
        android:id="@+id/imageView6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/tv_g_email"
        android:layout_toEndOf="@+id/tv_g_email"
        android:layout_toRightOf="@+id/tv_g_email"
        android:paddingBottom="05dp"
        android:paddingLeft="10dp"
        android:paddingRight="05dp"
        android:paddingTop="05dp"
        android:src="@drawable/ic_launcher" />

    <TextView
        android:id="@+id/tv_g_number"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/imageView6"
        android:layout_below="@+id/textView35"
        android:layout_toEndOf="@+id/imageView6"
        android:layout_toRightOf="@+id/imageView6"
        android:gravity="center"
        android:text="889845412" />
</RelativeLayout>

当您创建recyclerview时,通常会有列表中各个项目的布局,然后是包含实际recyclerview的布局。实际recyclerview的布局可能包含某种类型的填充或边距,这就是为什么它不能填满屏幕的原因

您需要检查该布局,而不是列表中单个项目的布局


您还没有发布包含recyclerview的布局,因此我们无法进行评估。

它可能会在视图的开始和结束处添加空格
填充内容
=
包装内容
,不是吗?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="2dp"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp"
    android:layout_marginTop="2dp"
    android:background="#EDEFF1">
<?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="match_parent"
    android:layout_marginBottom="2dp"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp"
    android:layout_marginTop="2dp"
    android:background="#EDEFF1">


    <TextView
        android:id="@+id/tv_g_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:padding="10dp"
        android:text="Ashton Kutcher" />

    <ImageView
        android:id="@+id/iv_g_del"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:padding="10dp"
        android:src="@drawable/ic_launcher" />

    <TextView
        android:id="@+id/textView33"
        android:layout_width="2dp"
        android:layout_height="match_parent"
        android:layout_alignBottom="@+id/tv_g_name"
        android:layout_toLeftOf="@+id/iv_g_del"
        android:layout_toStartOf="@+id/iv_g_del"
        android:background="#D6D7D9" />

    <ImageView
        android:id="@+id/iv_g_add"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_toLeftOf="@+id/textView33"
        android:layout_toStartOf="@+id/textView33"
        android:padding="10dp"
        android:src="@drawable/ic_launcher" />

    <TextView
        android:id="@+id/textView34"
        android:layout_width="2dp"
        android:layout_height="match_parent"
        android:layout_alignBottom="@+id/textView33"
        android:layout_toLeftOf="@+id/iv_g_add"
        android:layout_toStartOf="@+id/iv_g_add"
        android:background="#D6D7D9" />

    <TextView
        android:id="@+id/textView35"
        android:layout_width="match_parent"
        android:layout_height="2dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/iv_g_add"
        android:background="#D6D7D9" />

    <ImageView
        android:id="@+id/imageView5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignTop="@+id/textView35"
        android:paddingBottom="05dp"
        android:paddingLeft="10dp"
        android:paddingRight="05dp"
        android:paddingTop="05dp"
        android:src="@drawable/ic_launcher" />

    <TextView
        android:id="@+id/tv_g_email"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/imageView5"
        android:layout_below="@+id/textView35"
        android:layout_toEndOf="@+id/imageView5"
        android:layout_toRightOf="@+id/imageView5"
        android:gravity="center"
        android:text="pavanh.dev@gmail.com" />

    <ImageView
        android:id="@+id/imageView6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/tv_g_email"
        android:layout_toEndOf="@+id/tv_g_email"
        android:layout_toRightOf="@+id/tv_g_email"
        android:paddingBottom="05dp"
        android:paddingLeft="10dp"
        android:paddingRight="05dp"
        android:paddingTop="05dp"
        android:src="@drawable/ic_launcher" />

    <TextView
        android:id="@+id/tv_g_number"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/imageView6"
        android:layout_below="@+id/textView35"
        android:layout_toEndOf="@+id/imageView6"
        android:layout_toRightOf="@+id/imageView6"
        android:gravity="center"
        android:text="889845412" />
</RelativeLayout>