У меня разные макеты в моем приложении, я добавил код для изменения языка и тем самым изменил направление макета и сделал несколько шагов, используя эти шаги. из моих макетов переключается на RTL, но у меня есть 2 макета, которые все еще находятся в режиме макета LTR.Макеты еще LTR после того, как они были «вынуждены» для RTL
Шаги я сделал:
Добавить поддержку RTL в AndroidManifest.xml.
Используйте «start/end» вместо «left/right».
Изменить языки Код:
Locale locale = new Locale("ar");
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics());
Скриншот: Here
Планировка:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginTop="2.5dp"
android:layout_marginBottom="2.5dp"
card_view:cardUseCompatPadding="true"
android:id="@+id/cardView"
android:foreground="?attr/selectableItemBackground"
android:stateListAnimator="@anim/lift_on_touch">
<RelativeLayout
android:id="@+id/rvs"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.pkmmte.view.CircularImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:id="@+id/episode_icon"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_margin="10dp"
app:border_color="#EEEEEE"
app:border_width="0dp"
app:shadow="false" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="عنوان"
android:id="@+id/episode_title"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/episode_icon"
android:layout_toStartOf="@+id/episode_icon"
android:layout_marginRight="11dp"
android:layout_marginEnd="11dp" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
Стрелка назад & активность Стиль:
<style name="Detail" parent="AppTheme">
<item name="toolbarStyle">@style/Widget.Toolbar</item>
</style>
<style name="Widget.Toolbar" parent="@style/Widget.AppCompat.Toolbar">
<item name="navigationIcon">?attr/homeAsUpIndicator</item>
<item name="android:background">?attr/colorPrimary</item>
</style> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
В Android Studio, в режиме просмотра RTL, это правильно, но при реальном тестировании стрелка ошибочна, элементы неправильны, но FAB работает правильно, что является странным.