How to force rtl support for a view? - android

I've disabled and forced my application to not support rtl . Because it made lots of problems of views and layouts , this is my manifest code:
<application
android:name="ir.dizbon.persiandesigners.ParseApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="false"
android:theme="#style/AppTheme"
tools:replace="android:supportsRtl">
in one layout I add this code :
android:layoutDirection="rtl"
When I remove the manifest code ,the layout change the direction and works fine but I can't remove manifest codes .
I tried to change the direction pragmatically:
pass_l.setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
it doesn't work either .
How can I make my view to support rtl and get rtl ?

You can create different layout in android studio to support rtl.
Right click layout -> New -> Layout Resource File -> then choose Layout Direction Qualifier.

Related

Align horizontal LinearLayout from left to right [duplicate]

I've made an app, I've tested it and it was fine on my phone. But... when I gave the .apk to someone else whose phone language is RTL the whole layout broke and it messed up everything.
My question is - How can I force my app to use only LTR and disable the auto layout change which breaks my whole app design?
In your manifest file and inside the application tag add these two lines.
<manifest>
<application
.
.
.
android:supportsRtl="false"
tools:replace="android:supportsRtl" //(replace libraries' Rtl support with ours)
>
</application>
</manifest>
Note: (about second line)
Some libraries have support Rtl in their manifest file so if you want to use those libraries you must replace their manifest line of code with yours.
Android 4.2 added full native support for RTL layouts. To take advantage of RTL layout mirroring, simply make the following changes to your app:
Declare in your app manifest that your app supports RTL mirroring.
Specifically, add android:supportsRtl="true" to the
element in your manifest file.
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”. For
example, android:paddingLeft should become android:paddingStart. If
you want your app to work with versions earlier than Android 4.2 (the
app's targetSdkVersion or minSdkVersion is 16 or less), then you
should add “start” and end” in addition to “left” and “right”. For
example, you’d use both android:paddingLeft and android:paddingStart.
For more precise control over your app UI in both LTR and RTL mode, Android 4.2 includes the following new APIs to help manage View components:
android:layoutDirection — attribute for setting the direction of a
component's layout.
android:textDirection — attribute for setting the
direction of a component's text.
android:textAlignment — attribute
for setting the alignment of a component's text.
getLayoutDirectionFromLocale() — method for getting the
Locale-specified direction
-- Source & Credits --
Just add the following to the manifest
android:supportsRtl="false"
tools:replace="android:supportsRtl"
Just add something like this in your App Theme Style:
<item name="android:layoutDirection">ltr</item>
or
<item name="android:layoutDirection">rtl</item>
For React Native adding the following line in the manifest file was enough:
// android/app/src/main/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kidspodmobileclient">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:supportsRtl="false" // <== add this line here
It would be like the following screenshot:
RN version: 0.68.2

Layout changes if device setting is force RTL

How to override Android option RTL(Force RTL layout direction) to keep an app LTR. I have Tried to set an option in manifest.xml but it did not work
android:layoutDirection="ltr"
android:supportsRtl="false"
tools:replace="android:supportsRtl"

Translate android app a and make it force RTL

I'm new to android and i want to translate an app. to arabic and force RTL direction.
If anyone can help please.
Thank you
If you want to support Arabic for your app, follow the below steps :
1) Create resource file (res/values-ar/strings.xml) and put your content.
2) Mostly supportsRTl set as true. Check once in Manifest file.
Example:Creating Arabic resource file
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
3) Test it in your device by doing below settings changes :
Select locale(Arabic) in language option
"Force RTL layout direction" in Developer option.
Note : Developer option will be enabled once you select build number 7 times. (inside Settings/ About Phone)
You can find simple example in below link:
https://www.tutorialspoint.com/android/android_localization.htm

Home up button changes its direction when language is changed

I have two languages in my app, English and Urdu. When the language is changed to Urdu home up button changes its direction like this:
Please help me how can I fix this issue. I want arrow direction to be on left side
To support right to left screen layout, you have to android:supportsRtl="true" line in your manifest.xml For example:
<application
android:name=".Application"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
>
After writing this tag, the arrow button will appear on the right and other icons on the left.
For more information, see this post.
There is not issue and supportsRtl.
Because if
android:supportsRtl="true"
then view display from right-hand-side.
If false then it'll display as it is.
Can i have your manifest application tag and style which used there?

Formatting NumberPicker

My default NumberPicker looks like this:
I want it to look more like this:
I'm not married to the +/- thing, but I want a smaller widget that can fit on a screen along with other stuff. My understanding is that setting the theme in the Manifest to one based on Theme will do the trick, but no joy. Here is my Manifest entry:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/android:Theme.Holo.Light" >
I am using Android 4.3 platform and API 18 on my ADV.
What am I doing wrong?
Thanks.

Categories

Resources