我试图找出一种方法来对齐布局中的项目相对于包含的布局中的项目。
这里有一个直观表示: layout_below项目里面包含的布局
这里就是我要找的(这显然是行不通的)示例代码:
main.xml中
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<include
android:id="@+id/info"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
layout="@layout/info" />
//This would be the dark grey box
<RelativeLayout
android:layout_below="@id/item1">
</RelativeLayout>
</RelativeLayout>
included.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="50dp">
<ImageView
android:id="@+id/item1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:paddingLeft="100dp"/>
</RelativeLayout>
我假设来完成,这将是通过动态定位深灰色框代码的最佳方式,但我不知道从哪里开始。任何帮助都是极好的。
你不能做你想做的(从我的角度来看,你不会想这样做)。看看在代码中添加额外的窗口。 – Luksprog
所以这个解决方案为我工作https://stackoverflow.com/a/45450305/563735 –
所以这个解决方案已经为我工作。 https://stackoverflow.com/a/45450305/563735 –