gpt4 book ai didi

android - Xamarin.android 中的 Xamarin- Rtl 支持

转载 作者:行者123 更新时间:2023-11-29 01:10:56 25 4
gpt4 key购买 nike

我需要在我的应用程序中支持 Rtl,这就是我所做的

将所有出现的包含“left”和“right”的布局属性分别替换为“start”和“end”。例如,android:paddingLeft 应该变成 android:paddingStart

Reference

这是android studio如何渲染我的xml布局

enter image description here enter image description here

我的xml代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/layout"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="22.3dp"
android:layout_marginStart="22.3dp"
android:layout_marginRight="15.3dp"
android:layout_marginEnd="15.3dp"
android:layout_marginTop="19dp">



<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13.3sp"
android:textColor="@color/bluey_grey"
android:textAllCaps="true"
android:text="@string/language" />
<TextView
android:id="@+id/languageText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13.3sp"
android:textColor="@color/orange_two"
android:text="English" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="15dp"
android:background="@color/silver_two" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="18dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/notificationChk"
android:layout_toStartOf="@+id/notificationChk"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13.3sp"
android:textColor="@color/bluey_grey"
android:textAllCaps="true"
android:text="@string/push_notifications" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="11.7sp"
android:textColor="@color/cool_grey"
android:text="@string/pushNotificationDetails" />
</LinearLayout>
<android.support.v7.widget.AppCompatCheckBox
android:id="@+id/notificationChk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
app:buttonTint="@color/colorPrimary"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="15dp"
android:background="@color/silver_two" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="18dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/newsLatterChk"
android:layout_toStartOf="@+id/newsLatterChk"

android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13.3sp"
android:textAllCaps="true"
android:textColor="@color/bluey_grey"
android:text="@string/newsletter" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="11.7sp"
android:textColor="@color/cool_grey"

android:text="@string/newsLetterDetails" />
</LinearLayout>
<CheckBox
android:id="@+id/newsLatterChk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="15dp"
android:background="@color/silver_two" />
<TextView
android:text="Save"
android:layout_marginTop="20dp"
android:padding="10dp"
android:textSize="14.7dp"
android:textAllCaps="true"
android:layout_gravity="center"
android:gravity="center"
android:textColor="@color/orange_three"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/saveBtn" />
<TextView
android:id="@+id/logoutBtn"
android:text="@string/logout"
android:textAllCaps="true"
android:layout_marginTop="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="@color/tomato" />
<Space
android:layout_width="wrap_content"
android:layout_height="20dp" />
</LinearLayout>
</LinearLayout>

但是当我在 xamarin 中运行时,我得到的是 enter image description here

完全支持 Rtl 我想念什么??

这是我在 Xamarin Forums 中的帖子有关我的问题的更多详细信息

最佳答案

您仍在某些 View 中使用硬编码方向(右,左),我知道对于 < 17 API 支持但尝试在没有它的情况下进行编译。

您也可以在 View 中使用参数“layoutDirection”

   android:layoutDirection = "locale"
android:layoutDirection = "inherit"
android:layoutDirection = "rtl"
android:layoutDirection = "ltr"

引用:Native RTL support in Android 4.2

关于android - Xamarin.android 中的 Xamarin- Rtl 支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43166995/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com