4

有人知道为什么在切换到 rtl 时,ConstraintLayout 会居中所有元素吗?

android:supportsRtl="true"在清单中设置。

BookShelfActivity.java仅包含标准 onCreate 覆盖:

public class BookShelfActivity extends AppCompatActivity {
   @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_book_shelf);
    }
}

这是活动xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    android:id="@+id/activity_book_shelf"
    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"
    tools:context="com.hekayh.ereader.BookShelfActivity"
    android:layout_gravity="start"
    >

    <TextView
        android:text="TextView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/textView5"
        />

    <TextView
        android:text="AnotherTextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="start"
        android:id="@+id/textView6"
        app:layout_constraintEnd_toEndOf="@id/textView5"
        tools:layout_editor_absoluteX="277dp"
        app:layout_constraintTop_toTopOf="@+id/activity_book_shelf"
        android:layout_marginTop="42dp"/>

    <Button
        android:text="Button"
        android:layout_width="91dp"
        android:layout_height="51dp"
        android:id="@+id/button2"
        app:layout_constraintStart_toStartOf="@+id/activity_book_shelf"
        android:layout_marginStart="100dp"
        app:layout_constraintTop_toBottomOf="@+id/textView6"
        android:layout_marginTop="24dp"
        />
</android.support.constraint.ConstraintLayout>

在此处输入图像描述

4

1 回答 1

2

这是我之前报告的一个错误,它在 alpha 6 中得到解决 https://code.google.com/p/android/issues/detail?id=218979

但是还有另一个关于 rtl 的错误,我需要在这里通过评论来支持它 https://code.google.com/p/android/issues/detail?id=220103

更新: 开发人员提到第二个 RTL 错误已解决: https ://code.google.com/p/android/issues/detail?id=222556

于 2016-08-27T07:27:01.567 回答