Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Set SupportRTL in AndroidManifest for Specifed Activity

i removed Action Bar from all activities Then I put to specific activity an action bar and when i used SupportsRtl (in Specifed Activity) for change title position but title position still no changed

styles :

<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 :

<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>
like image 223
Nima Khalili Avatar asked Mar 06 '23 22:03

Nima Khalili


2 Answers

You can't do such thing in Manifest.xml.

I recommend set android:layoutDirection="rtl" into your activity parent layout to set just that specific activity support rtl.

this article has great information about layout directions support.

like image 143
alizeyn Avatar answered Apr 30 '23 16:04

alizeyn


When you enable support for RTL layouts like this:

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

You enable the use of this feature for every activity in the app.

This suggests that the problem probably lies in the layout of your AppBarLayout/ Toolbar.

In order for the application to properly reflect the direction, you should use the appropriate attributes - instead of using Left/Right, you should use Start/End ones. To read more check Android Developers Blog.

You can also use the automatic Android Studio option by selecting Refactor > Add RTL Support Where Possible...

enter image description here

like image 40
paulina_glab Avatar answered Apr 30 '23 14:04

paulina_glab