title: ActivityPreference does not use Right-to-Left resources when locale changes
body: <p>I'm currently developing an application which supports 3 languages base on <a href="https://proandroiddev.com/change-language-programmatically-at-runtime-on-android-5e6bc15c758" rel="nofollow noreferrer">Yaroslav Berezanskyi</a> codes. It's great and I can change application language at runtime but there is a problem which has confused me. Unfortunately when I want to go to ActivityPreference, the language and resources still remain in English and it doesn't use Right-to-Left resources such as layouts and strings when I change the app language to Farsi. What is the problem with Preference v7? I have attached some images from app when the language is English and Farsi. Thank in advance.</p>
  
  <p><strong>Change language method</strong></p>
  
  <pre><code>private static Context updateResources(Context context, String language) {
          Locale locale = new Locale(language);
          Locale.setDefault(locale);
  
          Resources res = context.getResources();
          Configuration config = new Configuration(res.getConfiguration());
          if (Build.VERSION.SDK_INT &gt;= 17) {
              config.setLocale(locale);
              context = context.createConfigurationContext(config);
          } else {
              config.locale = locale;
              res.updateConfiguration(config, res.getDisplayMetrics());
          }
          return context;
      }
  </code></pre>
  
  <p><strong>ActivityPreference codes</strong></p>
  
  <pre><code>public class ActivityPreference extends AppCompatActivity {
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_setting);
  
          if (savedInstanceState == null) {
              // Display the fragment as the main content.
              FragmentPreference fragmentPreference = FragmentPreference.newInstance();
              fragmentPreference.setArguments(this.getIntent().getExtras());
              this.getSupportFragmentManager().beginTransaction().replace(R.id.content, fragmentPreference).commit();
          }
      }
  }
  </code></pre>
  
  <p><strong>FragmentPreference codes</strong></p>
  
  <pre><code>public class FragmentPreference  extends PreferenceFragmentCompat {
  
      public static FragmentPreference newInstance(){
          FragmentPreference fr = new FragmentPreference();
          return fr;
      }
  
      @Override
      public void onStart() {
          super.onStart();
  
          int width = ViewGroup.LayoutParams.MATCH_PARENT;
          int height = ViewGroup.LayoutParams.MATCH_PARENT;
          FragmentPreference.this.getActivity().getWindow().setLayout(width, height);
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
      }
  
      @Override
      public void onCreatePreferences(Bundle bundle, String s) {
          addPreferencesFromResource(R.xml.preference);
      }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/JefjI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JefjI.png" alt="Preference Activity with English language"></a></p>
  
  <p><a href="https://i.stack.imgur.com/dxBWV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dxBWV.png" alt="Main menu off app when the language is English"></a></p>
  
  <p><a href="https://i.stack.imgur.com/1n5V9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1n5V9.png" alt="Preference Activity with Farsi language"></a></p>
  
  <p><a href="https://i.stack.imgur.com/1BwBM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1BwBM.png" alt="Main menu off app when the language is Farsi"></a></p>