【问题标题】:MaterialCardView is cutted off in RecyclerView in RTL modeRTL模式下RecyclerView中MaterialCardView被截断
【发布时间】:2021-06-24 13:03:14
【问题描述】:

我在项目中有RecyclerViewMaterialCardView 的应用程序。我看到,我的物品被切断了:

这是我的物品 xml 文件:

<?xml version="1.0" encoding="utf-8"?>
<layout 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">

    <data>


    </data>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <com.google.android.material.card.MaterialCardView
            android:layout_width="match_parent"
            android:layout_height="46dp"
            android:layout_marginTop="6dp"
            android:layout_marginBottom="6dp"
            app:cardCornerRadius="5dp"
            app:cardElevation="0dp"
            app:strokeColor="@color/silver"
            app:strokeWidth="1dp">

            <EditText
                android:id="@+id/editText"
                android:textColor="@color/gray"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:layout_gravity="center"
                android:layout_marginLeft="23dp"
                android:layout_marginRight="23dp"
                android:textSize="14dp"
                android:textColorHint="@color/grey"
                android:background="@color/colorPrimary"
                android:gravity="center_vertical"
                android:hint="text here"
                android:singleLine="true"
                android:textDirection="rtl"
                tools:text="sfsdf s fs fs" />

        </com.google.android.material.card.MaterialCardView>

    </RelativeLayout>
</layout>

而且我不知道如何解决它。此问题并非在所有设备上都重现,仅在三星上重现。我的应用程序处于 RTL 模式,也许问题与此有关。有办法解决吗?

【问题讨论】:

    标签: android android-relativelayout materialcardview


    【解决方案1】:

    这是最可能的问题来源。在您的代码中,有以下两个标签:

    <data>
        </data>
    

    你会尝试删除它们。似乎进入它们的内容与MateriallCardView

    重叠

    【讨论】:

    • 但是我需要那个标签,因为我在我的应用程序中使用了 DataBinding。在我附加的代码中,上面的数据是空的,但在应用程序中我这里有变量。
    • 肯定不是这个原因
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-04-27
    • 2021-08-30
    • 2019-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多