如何在 AndroidManifest 中为指定 Activity 设置 SupportRTL

How To Set SupportRTL in AndroidManifest for Specifed Activity

我从所有活动中删除了操作栏然后我将特定的 activity 操作栏放在特定的操作栏中,当我使用 SupportsRtl(在指定的 Activity 中)更改标题位置但标题位置仍然没有改变

样式:

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="myTheme" parent="Theme.AppCompat.Light">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:textColorPrimary">#FFFFFF</item>
</style>

</resources>

清单:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.user.classmanager">

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name=".FirstTab" />
    <activity android:name=".SecondTab" />
    <activity android:name=".ThirdTab" />

    <activity android:name=".AddNewClass"
        android:theme = "@style/myTheme"
        android:supportsRtl="true"  <==== DONT WORK
        android:label="اضافه کردن کلاس">
    </activity>
</application> </manifest>

当您像这样启用对 RTL 布局的支持时:

<application
    ...
    android:supportsRtl="true">

您为应用程序中的 每个 activity 启用此功能。

这表明问题可能出在您的 AppBarLayout/ Toolbar.

的布局上

为了让应用程序正确反映方向,您应该使用适当的属性 - 而不是使用 Left/Right,您应该使用 Start/End 一个。要阅读更多信息,请查看 Android Developers Blog.

您还可以使用自动 Android Studio 选项,方法是选择 Refactor > Add RTL Support Where Possible...

你不能在Manifest.xml做这样的事情。

我建议将 android:layoutDirection="rtl" 设置到您的 activity 父布局中以设置特定的 activity 支持 rtl。

this article has great information about layout directions support.