vlozful
vlozful

Reputation: 43

How to make ConstraintLayout work properly for RTL?

Does somebody know why when switching to rtl, ConstraintLayout centers all elements?

android:supportsRtl="true" in manifest is set.

BookShelfActivity.java contains only standard onCreate override:

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

Here is the activity 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>

enter image description here

Upvotes: 4

Views: 1840

Answers (1)

amorenew
amorenew

Reputation: 10896

it's a bug i reported before and it get solved in alpha 6 https://code.google.com/p/android/issues/detail?id=218979

but there is another bug about rtl i need to support it by a comment here https://code.google.com/p/android/issues/detail?id=220103

Updates: developer mentioned that second RTL bug solved: https://code.google.com/p/android/issues/detail?id=222556

Upvotes: 2

Related Questions