【问题标题】:How to make ConstraintLayout work properly for RTL?如何使 ConstraintLayout 为 RTL 正常工作?
【发布时间】:2016-07-13 15:42:17
【问题描述】:

有人知道为什么在切换到 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>

【问题讨论】:

  • 我相信这是一个错误。
  • 是的,这绝对是一个错误,但可能有人试图使用约束布局的源代码来修复它.. -
  • 发现最新的com.android.support.constraint:constraint-layout:1.0.0-alpha6好像没有这个。
  • 我投了赞成票只是因为它是一个关于糟糕图书馆的问题

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


【解决方案1】:

这是我之前报告的一个错误,它在 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

【讨论】:

    猜你喜欢
    • 2018-01-19
    • 1970-01-01
    • 2020-07-24
    • 2018-12-06
    • 1970-01-01
    • 1970-01-01
    • 2018-06-15
    • 1970-01-01
    • 2020-07-25
    相关资源
    最近更新 更多