Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8644595

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:20:07+00:00 2026-06-12T12:20:07+00:00

my application has two language.right to left and left to right. i change locale

  • 0

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?

  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:20:09+00:00Added an answer on June 12, 2026 at 12:20 pm

    do what’s explain here:
    android dynamically change style at runtime

    and for resume problem:
    just try to recall setContentView() in onResume like this:

    @Override
     protected void onResume() {
         if(selectedLang.equalsIgnoreCase("fa"))
        context.setTheme(R.style.CustomTheme_DirectionRight);
         else
        context.setTheme(R.style.CustomTheme_DirectionLeft);
         super.onResume();
         setContentView(R.layout.content);
         findAgainViews();//because recalling setContentView reset all findViewById()
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My application has one activity which starts two services but does not bind them.
My application has two layouts A and B. In A a user chooses some
My application has two node types: a parent node which can hold recursive child
I have an application that has two localization options at the moment through .resx
I have an application that has two threads. The first one (the main thread)
I'm trying to build an iPhone application that has two subviews in the main
I would like to create a UIBarButtonItem on my iPhone application which has two
I am working on a simple app tab-bar based application that has two views.
Our product has two clients, a website and a windows application. Both clients need
I'm working on a project that has two modules: a web and an application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.