[英]layout_below item inside included layout
I'm trying to figure out a way to align an item in a layout in respect to an item within an included layout. 我试图想出一种方法来对齐布局中的项目相对于包含的布局中的项目。
Here's a visual representation: 这是一个直观的表示:
And here is example code that I'm looking for (which obviously doesn't work): 这是我正在寻找的示例代码(显然不起作用):
Main.xml 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 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>
I'm assuming the best way to accomplish this would be through dynamically positioning the dark grey box in code, but I have no idea where to start. 我假设最好的方法是通过在代码中动态定位深灰色框,但我不知道从哪里开始。 Any help would be awesome.
任何帮助都是极好的。
Can you make this below your include? 你可以在你的包含下面做这个吗? Something like this (instead item1 use info):
像这样的东西(而不是item1使用信息):
<?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/info">
</RelativeLayout>
</RelativeLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.