Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/201.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 如何配置布局的xml以防止切字?_Android_Xml_Android Layout - Fatal编程技术网

Android 如何配置布局的xml以防止切字?

Android 如何配置布局的xml以防止切字?,android,xml,android-layout,Android,Xml,Android Layout,我对XML的切字有问题,请看下图: 正如您所看到的,单词Delete被剪切。以下是我对该部分的布局: <LinearLayout android:layout_width="wrap_content" android:layout_height="match_parent" android:gravity="end" android:orientation="horizontal" android:weigh

我对XML的切字有问题,请看下图:

正如您所看到的,单词Delete被剪切。以下是我对该部分的布局:

<LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:gravity="end"
        android:orientation="horizontal"
        android:weightSum="30"
        android:baselineAligned="false">

        <RelativeLayout
            android:id="@+id/more_btn"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_gravity="center_vertical"
            android:layout_weight="10"
            android:background="@color/gray_light"
            android:paddingStart="10dp"
            android:paddingEnd="10dp">

            <ImageView
                android:id="@+id/pict_1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:background="@drawable/ic_more"
                android:drawablePadding="10dp" />


            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center_vertical"
                android:text="More"
                android:layout_below="@id/pict_1"
                android:textAlignment="center"
                android:textColor="@color/white"
                android:textSize="12sp" />

        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/archive"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="10"
            android:background="@color/colorAccent"
            android:paddingStart="5dp"
            android:paddingEnd="5dp">

            <ImageView
                android:id="@+id/pict_2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:background="@drawable/ic_inbox"
                android:contentDescription="TODO" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Archive"
                android:layout_below="@id/pict_2"
                android:textColor="@color/white"
                android:textSize="12sp" />
        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/delete"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_gravity="center_vertical"
            android:layout_weight="10"
            android:background="#FF0000"
            android:paddingStart="10dp"
            android:paddingEnd="10dp">

            <ImageView
                android:id="@+id/pict_3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:background="@drawable/ic_delete"
                android:drawablePadding="10dp" />


            <TextView
                android:layout_below="@id/pict_3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Delete"
                android:textAlignment="viewStart"
                android:textColor="@color/white"
                android:textSize="12sp" />

        </RelativeLayout>
    </LinearLayout>

一般来说,我注意到这是由填充引起的,填充将元素拉入父布局中。我试图改变它,但我发现word Archive也会受到影响。如何使用错误的布局xml解决此问题?

添加第三个布局删除,并使用包装内容和权重,如下所示

<RelativeLayout
        android:id="@+id/delete"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="center_vertical"
        android:layout_weight="10"
        android:background="#FF0000"
        android:paddingStart="10dp"
        android:paddingEnd="10dp">

        <ImageView
            android:id="@+id/pict_3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:background="@drawable/ic_delete"
            android:drawablePadding="10dp" />


        <TextView
            android:layout_below="@id/pict_3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Delete"
            android:textAlignment="viewStart"
            android:textColor="@color/white"
            android:textSize="12sp" />

    </RelativeLayout>

在上一次相亲中,你需要额外的5 dp。中间一个有5个dp,但最后一个有10个dp。对于第一个,多个有4个字符,但最后一个删除有6个字符。所以现在比较存档7个字符和5个dp填充。@Tariquislam,现在我看到我的布局中有10-5-10个填充