my application has two language.right to left and left to right. i change locale inside of application(not from phone setting). and reload data on resume() function to see changes on UI. i have two folders for values.one values-en, one values-fa. to change direction of textview to RTL and LTR,put two styles.xml in these folders. styles.xml (values-en) :
<?xml version="1.0" encoding="utf-8"?>
<resources
xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Direction">
<item name="android:gravity">left</item>
<item name="android:layout_gravity">left</item>
</style>
</resources>
styles.xml (values-fa) :
<?xml version="1.0" encoding="utf-8"?>
<resources
xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Direction">
<item name="android:gravity">right</item>
<item name="android:layout_gravity">right</item>
</style>
</resources>
and to use this style,for example i do it:
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/menutext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="@style/Direction"
android:padding="0dp"/>
</RelativeLayout>
if i run application,everything is ok,and direction of textview is related to locale.problem is here that when i change language from app's setting from option menu,data load correct,but direction not.and i'm should go to another activity to see changes of direction.
to solve this problem,can i remove styles.xml because of i'm using Html.fromHtml() and my data have
<p dir="LTR">
and
<p dir="RTL">
tags?
another probable solution(thanks to TOMCA for comment) : android dynamically change style at runtime
but problem still alive.anybody have a idea?