强制到rtl后布局错误的位置和宽度

时间:2018-04-19 09:30:47

标签: android android-layout right-to-left

我强迫我的项目使用Android工作室重构菜单的rtl,我的滑块显示错误的宽度,我尝试更改xml文件中的所有父和嵌套元素与不同的attrbiutes,如     android:AlignParentLeft 在完成测试设备的构建后,显示错误的位置和宽度。

重构之前的屏幕截图强制rtl: before refactor to force rtl

强制rtl的重构后的屏幕截图: after refactor to force rtl

布局xml内容:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="@dimen/spacing_medium"
    android:layout_marginLeft="@dimen/spacing_middle"
    android:layout_marginRight="@dimen/spacing_middle"
    android:layout_marginTop="@dimen/spacing_mlarge"
    android:text="@string/title_what_news"
    android:textAppearance="@style/Base.TextAppearance.AppCompat.Title"
    android:textColor="@color/grey_60" />

<RelativeLayout
    android:layout_width="match_parent"
    android:layoutDirection="rtl"
    android:layout_height="wrap_content"
    android:minHeight="@dimen/min_height_featured_news">

    <android.support.v7.widget.CardView
        android:id="@+id/lyt_cart"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="@dimen/spacing_medium"
        android:layout_marginLeft="@dimen/spacing_middle"
        android:layout_marginRight="@dimen/spacing_middle"
        android:layout_marginTop="@dimen/spacing_medium"
        android:clipToPadding="false"
        android:visibility="visible"
        app:cardBackgroundColor="@android:color/white"
        app:cardCornerRadius="4dp"
        app:cardElevation="1dp"
        app:cardUseCompatPadding="false">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="0dp"
                android:layout_weight="1">

                <android.support.v4.view.ViewPager
                    android:id="@+id/pager"
                    android:layout_width="match_parent"
                    android:layout_height="200dp"
                    android:layout_alignParentEnd="true"
                    android:layout_alignParentTop="true"
                    android:background="@color/grey_20" />

                <ImageButton
                    android:id="@+id/bt_previous"
                    android:layout_width="@dimen/spacing_mlarge"
                    android:layout_height="@dimen/spacing_xlarge"
                    android:layout_alignParentLeft="true"
                    android:layout_centerVertical="true"
                    android:background="@color/darkOverlaySoft"
                    android:src="@drawable/ic_arrow_left" />

                <ImageButton
                    android:id="@+id/bt_next"
                    android:layout_width="@dimen/spacing_mlarge"
                    android:layout_height="@dimen/spacing_xlarge"
                    android:layout_alignParentRight="true"
                    android:layout_centerVertical="true"
                    android:background="@color/darkOverlaySoft"
                    android:src="@drawable/ic_arrow_right" />

            </RelativeLayout>

            <View
                android:layout_width="match_parent"
                android:layout_height="1px"
                android:background="@color/grey_10" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@android:color/white"
                android:gravity="center"
                android:orientation="horizontal"
                android:padding="@dimen/spacing_large">

                <TextView
                    android:id="@+id/featured_news_title"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:maxLines="1"
                    android:singleLine="true"
                    android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"
                    android:textColor="@color/colorPrimaryDark" />

                <LinearLayout
                    android:id="@+id/layout_dots"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_marginLeft="@dimen/spacing_large"
                    android:gravity="end|center_vertical"
                    android:orientation="horizontal" />

            </LinearLayout>
        </LinearLayout>

    </android.support.v7.widget.CardView>

</RelativeLayout>

</LinearLayout>

0 个答案:

没有答案