RTL is forced in RTL devices

前端 未结 4 1954
粉色の甜心
粉色の甜心 2021-01-31 17:38

The new version of React Native has issued support for RTL devices: https://facebook.github.io/react-native/blog/2016/08/19/right-to-left-support-for-react-native-apps.html

相关标签:
4条回答
  • 2021-01-31 17:52

    @atlanteh's answer is right. I am just giving you a detailed answer for those who have the ios background and not much aware of the Android.

    first, try once. if 1st one does not work then try 2. If still not work then try both. then it will show expected output.

    Answer 1

    MainApplication.java

    public class MainApplication extends Application implements ReactApplication {
        @Override
        public void onCreate() {
            super.onCreate();
    
            // FORCE LTR
            I18nUtil sharedI18nUtilInstance = I18nUtil.getInstance();
            sharedI18nUtilInstance.allowRTL(getApplicationContext(), false);
            ....
        }
    }
    

    Answer 2

    AndroidManifest.xml

    i have add the android:supportsRtl="false" in application tag

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.appname">
        ........
        <application 
          android:supportsRtl="false"
          android:name=".MainApplication"
          android:label="@string/app_name"
          android:icon="@mipmap/ic_launcher"
          android:roundIcon="@mipmap/ic_launcher_round"
          android:allowBackup="false"
          android:theme="@style/AppTheme">
          android:name="com.facebook.react.devsupport.DevSettingsActivity" />
           ....
        </application>
    
    </manifest>
    
    0 讨论(0)
  • 2021-01-31 18:01

    I managed to fix this by adding to MainApplication.java:

    import com.facebook.react.modules.i18nmanager.I18nUtil;
    
    public class MainApplication extends Application implements ReactApplication {
        @Override
        public void onCreate() {
            super.onCreate();
    
            // FORCE LTR
            I18nUtil sharedI18nUtilInstance = I18nUtil.getInstance();
            sharedI18nUtilInstance.allowRTL(getApplicationContext(), false);
            ....
        }
    }
    
    0 讨论(0)
  • 2021-01-31 18:07

    In manifest.xml file add android:supportsRtl="false" to your application tag

    0 讨论(0)
  • 2021-01-31 18:09

    if you are using Expo

    import { I18nManager} from 'react-native';
    I18nManager.allowRTL(false);
    
    export default class <className> extends Component {
    
    
    
    }
    
    0 讨论(0)
提交回复
热议问题