我試圖找出一種方法來對齊佈局中的項目相對於包含的佈局中的項目。
這裏有一個直觀表示: 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 –