我正在设计并测试它:
看起来S3的某些相对布局命令表现不佳,例如:
以下简化问题:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Button" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/button1"
android:layout_toEndOf="@id/button1"
android:text="Button" />
</RelativeLayout>
由于我在缩放和相互关联的图片方面工作很多,所以这个功能非常重要。
如果有人可以与我分享他们的经历,我会很感激。
由于
编辑:拼写错误
答案 0 :(得分:1)
首先,没有android:layout_toEndOf="@id/button1"
等资源。
相对布局只有2个资源可根据任何窗口小部件{id} toLeftOf
进行排列,toRightOf
检查您的代码。
修改强>
最近在API级别17中添加了 toEndOf
和toStartOf
,即android 4.2版本,因此在较低版本的android中找不到它
答案 1 :(得分:0)
遇到了同样的问题:
我使用ToStartOf和toEndOf将固定大小的图形对齐到缩放的1px宽图形。
[Graphic 1]&lt; - [Graphic 2(1px scaled to 20dp)]&lt; - [Graphic 3]
从右到左构建时,它们无法正确对齐。当你说左边的缩放图形时,新图形将保留原始尺寸的图像而不是缩放图像的末尾 - 因此重叠。
[Grap [hic 1 Gra] phic 2] [Graphic 3]
workarround可以从左到右构建图形,将所有元素作为模块放在相对布局中,并将不同模块相互对齐。
使用ToStartOf和ToEndOf函数的API级别信息的Thx!