为什么我的一些看法不是我的亲戚布局的底部正确对齐? [英] Why are some of my views not aligned correctly at the bottom of my relative layout?
问题描述
我已经得到了一些在我的ListView我一个行内使用相对布局对准我的看法的问题。
I have problems getting some of my views aligned in a relative layout that I use inside a row of my listview.
下面是Eclipse中的布局建设者截图,这是我认为它应该是这样的:
Here is a screenshot from the layout builder in Eclipse, this is what I think it should look like:
接下来的图像是从仿真器。现在TestTestTest视图是在顶部和覆盖所述名称和距离Textviews。
The next image is from the emulator. Now the TestTestTest View is at the top and covers the name and distance Textviews.
这是我的布局:
<?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"
android:padding="4dip">
<ImageView android:id="@+id/logo" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:adjustViewBounds="true"
android:scaleType="centerInside" android:src="@drawable/icon"
android:layout_centerVertical="true" android:layout_alignParentLeft="true"
android:background="@color/green" />
<TextView android:id="@+id/distance" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Distance"
android:layout_alignParentRight="true" android:layout_alignParentTop="true"
android:paddingRight="4dip" android:background="#000000" />
<TextView android:id="@+id/name" android:layout_width="fill_parent"
style="@style/ListHeadText" android:layout_height="wrap_content"
android:text="Name"
android:layout_alignTop="@id/distance" android:layout_toRightOf="@id/logo"
android:layout_toLeftOf="@id/distance" android:gravity="clip_horizontal"
android:lines="1" android:paddingLeft="4dip" android:background="@color/red" />
<TextView android:id="@+id/number" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Number"
android:paddingRight="4dip" android:layout_alignRight="@id/distance"
android:background="@color/darkred" android:layout_below="@id/distance" />
<TextView android:id="@+id/subcategory" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Subcategory"
android:paddingLeft="4dip" android:layout_alignLeft="@id/name"
android:lines="1" android:gravity="clip_horizontal"
android:layout_below="@id/distance" android:background="@color/green" />
<TextView android:id="@+id/test" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="TestTestTest"
android:paddingLeft="4dip"
android:layout_alignParentBottom="true" android:gravity="bottom"
android:background="@color/red" />
不应该align_parent_bottom放视图在小区的列表中的底部
Shouldnt align_parent_bottom put the view at the bottom of the cell in the list?
推荐答案
尝试添加的android:layout_alignParentLeft =真正的
为好;有时,如果它不能,至少2点固定的观点意见无法正常显示。此外,这是RelativeLayout的一个ListView中使用?如果是这样,你可能会发现你有一定的难度得到它看的权利。有<一个href=\"http://stackoverflow.com/questions/2451744/how-do-i-vertically-align-an-item-within-a-list-using-relative-layout\">another问题在哪里有人有地方RelativeLayout的看着权本身就是一个问题,但不是一旦它被列为一个ListView的一部分。我们没能找出了问题让他不得不使用嵌套LinearLayouts来代替。
Try adding android:layout_alignParentLeft="true"
as well; sometimes Views aren't displayed properly if it can't anchor the view with at least 2 points. Also, is this RelativeLayout used within a ListView? If so, you might find you have some difficulty getting it to look right. There was another question where someone was having a problem where the RelativeLayout looked right on its own, but not once it was included as part of a ListView. We didn't manage to figure out what went wrong so he had to use nested LinearLayouts instead.
这篇关于为什么我的一些看法不是我的亲戚布局的底部正确对齐?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!