Skip to content

Commit

Permalink
Update layout direction (e.g. RTL) as needed
Browse files Browse the repository at this point in the history
  • Loading branch information
rosenpin authored and ocram committed Jan 21, 2017
1 parent 61e6061 commit 228ab5d
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.preference.PreferenceManager;
import java.util.Locale;
import android.content.ContextWrapper;
Expand Down Expand Up @@ -119,6 +120,11 @@ public static void set(final ContextWrapper context, final String languageCode,
final Configuration conf = resources.getConfiguration();

conf.locale = newLocale;

if (Build.VERSION.SDK_INT >= 17) {
conf.setLayoutDirection(conf.locale);
}

resources.updateConfiguration(conf, resources.getDisplayMetrics());

// overwrite the default Locale
Expand Down

0 comments on commit 228ab5d

Please sign in to comment.