![](/img/trans.png)
[英]How to align the content of a RelativeLayout to the right of an ImageView?
[英]How can I use RelativeLayout to align buttons to the right of an ImageView
我正在为一个简单的相对布局而苦苦挣扎。 应该在左边有一个图像,在右边有一列其他视图。 垂直对齐是正确的,但是水平对齐使图像左侧的按钮非常令人费解,即使我要求它们位于右侧。
谁能解释:
这是布局xml和屏幕截图:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/widget51"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:id="@+id/ivLove"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_centerHorizontal="true"
/>
<TextView
android:id="@+id/tvDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:hint="Image name"
android:layout_toRightOf="@+id/ivImage"
/>
<TextView
android:id="@+id/tvPage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Page URL"
android:layout_below="@+id/tvDate"
android:layout_toRightOf="@+id/ivImage"
/>
<Button
android:id="@+id/btnNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Next"
android:layout_below="@+id/tvPage"
android:layout_toRightOf="@+id/ivImage"
/>
<Button
android:id="@+id/btnPrevious"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Previous"
android:layout_below="@+id/btnNext"
android:layout_toRightOf="@+id/ivImage"
/>
</RelativeLayout>
如果您想了解图像,请参阅Android:使用AsyncTask的简单HTML解析和图像下载器
您将这些控件( TextView
, Button
)放在id为ivImage的ImageView
右侧 。
但是,您的布局不包含任何具有该ID的ImageView(但具有ivLove的ImageView )。 控件显示在左侧,因为这是RelativeLayout
内视图的默认对接。
尝试更新您的引用(将每个“ ivImage ”替换为“ ivLove ”。
注意-如果使用Eclipse ,则没有得到编译错误的原因是,您的项目中某处可能有ImageView
带有android:id="ivImage"
。 启用(并可能更新)棉绒将帮助您过滤此类问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.