Skip to content
This repository has been archived by the owner on Jun 22, 2022. It is now read-only.

Change layout direction when language changed #27

Closed
emadimehrdad opened this issue Aug 4, 2018 · 6 comments
Closed

Change layout direction when language changed #27

emadimehrdad opened this issue Aug 4, 2018 · 6 comments

Comments

@emadimehrdad
Copy link

Hi, how can i change layout direction when a user changes his app's language

@JanuszHain
Copy link

if resources put in localized packages doesn't work, put strings in string xmls, different for each language, read and and depending on it change layout direction in code - quick shot, I guess it is doable

@dimkinware
Copy link

I'm using next code in BaseActivity class

    @Override
    public void setContentView(@LayoutRes int layoutResID) {
        super.setContentView(layoutResID);
        View v = findViewById(android.R.id.content);
        if(v!=null) {
            Locale locale = LanguageSetting.getLanguage(this);
            v.setLayoutDirection(TextUtils.getLayoutDirectionFromLocale(locale));
        }
    }

@yosefi1988
Copy link

@dimkinware TNX

@Rissmon
Copy link

Rissmon commented Jan 3, 2020

@dimkinware It worked. Thanks
@akexorcist Thanks for this awsome work.

@akexorcist
Copy link
Owner

@dimkinware Does #10 solution work as well? I just merged it to 1.2.4

@dimkinware
Copy link

@dimkinware Does #10 solution work as well? I just merged it to 1.2.4

Looks like yes

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants