Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio - Activity's layout shows flipped (RTL instead of LTR)

I have this issue in my App, which is super weird.

I have an app, when i press Run on Android Studio, it starts the app with the correct layout's direction. Now, i press Back button and go back to the app, it shows a RTL layout instead of the current, correct LTR layout.

The app is pretty simple, it has an Activity with a NavigationButton in the Toolbar, when its flipped, the NavigationButton goes from left to the right, with a false pointing direction.

The app is LTR, supports only English, and tested on an English device, the same result is happening on the Emulator. I have the final version of Android Studio.

  • Layout, with Toolbar, along with navigation attribute, to enable back arrow.
  • Activity which setContentView and just shows the layout.
  • Back pressing, or re-opening the App without clearing it from the BackStack, shows the visual bug.

What cause the issue? as the code is pretty simple and doesn't have anything hardcore.

Manifest Code:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.corF.app">
<uses-permission android:name="android.permission.INTERNET"/>
<application
    android:supportsRtl="true"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:theme="@style/AppTheme">
    <activity
        android:name="com.corF.app.activities.ActivityStartup"
        android:label="@string/app_name"
        android:windowSoftInputMode="adjustResize|stateHidden">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
</manifest>
like image 980
Jaeger Avatar asked Dec 21 '17 16:12

Jaeger


People also ask

How do I change RTL on android?

Just go to Android Studio > Refactor > Add RTL support where possible… I would recommend you checking your app once after applying this change as you might not want all your Layouts/Views to be RTL. If you want to force any layout to LTR then just add android:layoutDirection="ltr" to that view.

How do I disable RTL on android?

How do I disable RTL support on android? Change all of your app's "left/right" layout properties to new "start/end" equivalents. If you are targeting your app to Android 4.2 (the app's targetSdkVersion or minSdkVersion is 17 or higher), then you should use “start” and “end” instead of “left” and “right”.

How do I enable RTL support on android?

First of all, you must add android:supportsRtl="true" to the <application> element in your manifest file for your app to supporting RTL design. Trick: If your app supports multiple languages and if you have code snippet like config. setLayoutDirection(Locale.US) you must change it.

What is Force RTL layout direction?

This layout is for the languages which is written from right to left like Arabic languages. On checking this option you will force the layout and check if the text and other views are properly aligned to the language direction.


1 Answers

A library which i use (SliderLayout), has a code which forces the app to show RTL. On the first launch the SliderLayout forces the RTL, but it doesn't take change until i re-open the app without fully removing it from the backstack.

Silly issue, but yeah, this's the solution.

like image 83
Jaeger Avatar answered Oct 20 '22 11:10

Jaeger