如何从Android源代码移植RelativeLayout? 背景
我有一个像卡一样的UI,它使用了一个RelativeLayout 问题 最近我发现,至少在一台设备上(或rom,或ANDROID版本),当我切换到RTL语言(如希伯来语)时,一切都变得一团糟 这只发生在使用Android V4.2.2的LG G2上。 我看到的是: 如果你将其与应用程序的屏幕截图进行比较,你会发现这并不是它应有的样子 即使在我检查过的所有Android设备上,在所有模拟器上,我都从未见过它(即使切换到希伯来语) 我试过的 我曾尝试使用一个工具来修复它,但效果不好(链接到这里) 我也尝试过使用LinearLayout,但考虑到它可能有问题,我改用了它。它可以工作,但不建议使用这么多 我尝试过的另一件事是移植Android源代码的相对性,但这给了我很多很难处理的警告和错误 这里是布局的原始XML,顺便说一句(我删除了不相关的内容,使其更简短):如何从Android源代码移植RelativeLayout? 背景,android,android-layout,android-relativelayout,Android,Android Layout,Android Relativelayout,我有一个像卡一样的UI,它使用了一个RelativeLayout 问题 最近我发现,至少在一台设备上(或rom,或ANDROID版本),当我切换到RTL语言(如希伯来语)时,一切都变得一团糟 这只发生在使用Android V4.2.2的LG G2上。 我看到的是: 如果你将其与应用程序的屏幕截图进行比较,你会发现这并不是它应有的样子 即使在我检查过的所有Android设备上,在所有模拟器上,我都从未见过它(即使切换到希伯来语) 我试过的 我曾尝试使用一个工具来修复它,但效果不好(链接到这里)
问题
当我使用RelativeLayout时,如何从Android的官方源代码移植代码
是否有一个库可以做到这一点?解决这个问题可能会更容易,尝试从框架中提取RelativeLayout。您希望在这个屏幕上看到什么(我在您的应用程序列表中找不到类似的应用程序)?我已将该应用程序的链接放入其中,以便您可以看到应该显示的屏幕截图。此处:。查看第一张图像(左侧的一张),忽略(多重选择的)上部。我已经尝试过多个属性,奇怪的是它出现在一个非常特定的配置上:G2,Android 4.2.2,希伯来语。在所有其他设备和配置上,我没有这个问题。我现在也发布了我最初使用的XML布局。希望能有所帮助。LINT对RTL布局支持有何看法?它通常给出关于可能的RTL问题的提示。您是否尝试过将
layoutDirection
属性与locale
值一起使用?layoutdirection是在4.2+中引入的,我的建议是尝试使用线性布局作为父级,并在其中添加相关布局。。这样你就不会在设计中遇到任何问题
<?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>