我在my app上有一个类似卡片的用户界面,它使用了RelativeLayout。
最近我发现在至少一个设备(或rom或ororid版本)上,当我切换到RTL语言(例如希伯来语)时,一切都搞砸了。
仅在使用Android V4.2.2的LG G2上发生过这种情况。 这就是我所看到的:
如果您将其与应用的屏幕截图进行比较,您会发现这不是它的样子。
即使在我检查过的所有Android设备上,以及在所有模拟器上,我也从未见过它(即使转换为希伯来语)。
我尝试使用GridLayout instead修复它,但效果不佳(链接在这里)。
我也尝试使用LinearLayout,但考虑到它可能存在问题,我使用了LinearLayoutCompat代替。它有效,但不建议使用这么多。
我尝试过的另一件事是移植Android源代码的RelativeLayout,但是这给了我很多很难处理的警告和错误。
这是布局的原始XML,BTW(我删除了不相关的东西,使其更短):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="afterDescendants" >
<ImageView
android:id="@+id/appIconImageView"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:adjustViewBounds="true"
android:src="@android:drawable/sym_def_app_icon" />
<LinearLayout
android:id="@+id/appDetailsContainer"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@+id/appIconImageView"
android:layout_toLeftOf="@+id/overflowView"
android:layout_toRightOf="@+id/appIconImageView"
android:layout_toStartOf="@+id/overflowView"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:text="label" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="description" />
</LinearLayout>
<ImageView
android:id="@+id/overflowView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@android:drawable/sym_def_app_icon" />
<ImageView
android:id="@+id/isSystemAppImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:src="@android:drawable/sym_def_app_icon" />
</RelativeLayout>
当我使用RelativeLayout时,如何从Android的官方源代码中移植代码?
是否有可以使用它的库?