RelativeLayout的正在全屏的WRAP_CONTENT [英] RelativeLayout is taking fullscreen for wrap_content
问题描述
为什么FOOBARZ得到奠定了所有的方式在底部时,没有任何元素, layout_height =FILL_PARENT
换句话说,所有的元素都WRAP_CONTENT的高度?
< XML版本=1.0编码=UTF-8&GT?;
< RelativeLayout的
的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT>
<的TextView
机器人:ID =@ + ID / feed_u
机器人:layout_width =50dip
机器人:layout_height =50dip
机器人:layout_marginLeft =5dip
机器人:scaleType =centerCrop
机器人:drawableTop =@机器人:可绘制/ presence_online
机器人:文本=U/>
< RelativeLayout的
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_toRightOf =@ ID / feed_u>
< ImageView的
机器人:ID =@ + ID / feed_h
机器人:layout_alignParentRight =真
机器人:layout_alignParentTop =真
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:SRC =@机器人:可绘制/ btn_minus/>
< ImageView的
机器人:ID =@ + ID / feed_ha
机器人:layout_toLeftOf =@ ID / feed_h
机器人:layout_alignParentRight =真
机器人:layout_alignParentTop =真
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:SRC =@机器人:可绘制/ btn_plus/>
<的TextView
机器人:ID =@ + ID / feed_t
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:文本=标题>
< / TextView的>
<的TextView
机器人:ID =@ + ID / feed_a
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:文本=带
机器人:layout_below =@ ID / feed_t>
< / TextView的>
<的TextView
机器人:ID =@ + ID / feed_s
机器人:layout_below =@ ID / feed_a
机器人:文本=S
机器人:layout_height =WRAP_CONTENT
机器人:layout_width =WRAP_CONTENT>
< / TextView的>
<的TextView
机器人:ID =@ + ID / feed_tm
机器人:layout_alignParentBottom =真
机器人:layout_alignParentRight =真
机器人:文本=FOOBARZ
机器人:layout_height =WRAP_CONTENT
机器人:layout_width =WRAP_CONTENT>
< / TextView的>
< / RelativeLayout的>
< / RelativeLayout的>
在 RelativeLayout的
DOC:
类概述
,其中儿童的位置可以相对于所述彼此或与母体阿布局
请注意,你不能有RelativeLayout的大小和它的孩子们的位置之间循环依赖。 例如,你不能有一个RelativeLayout的,其高度设置为WRAP_CONTENT和一个孩子设置为ALIGN_PARENT_BOTTOM
这正是你的情况。 RelativeLayout的不能做到这一点。
Why does FOOBARZ get layed out all the way at the bottom when no elements are layout_height="fill_parent"
in other words, all elements are wrap_content for height?
<?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="wrap_content">
<TextView
android:id="@+id/feed_u"
android:layout_width="50dip"
android:layout_height="50dip"
android:layout_marginLeft="5dip"
android:scaleType="centerCrop"
android:drawableTop="@android:drawable/presence_online"
android:text="U" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/feed_u">
<ImageView
android:id="@+id/feed_h"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_minus" />
<ImageView
android:id="@+id/feed_ha"
android:layout_toLeftOf="@id/feed_h"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_plus" />
<TextView
android:id="@+id/feed_t"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title">
</TextView>
<TextView
android:id="@+id/feed_a"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Band"
android:layout_below="@id/feed_t">
</TextView>
<TextView
android:id="@+id/feed_s"
android:layout_below="@id/feed_a"
android:text="S"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
</TextView>
<TextView
android:id="@+id/feed_tm"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="FOOBARZ"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
</TextView>
</RelativeLayout>
</RelativeLayout>
From the RelativeLayout
doc:
Class Overview
A Layout where the positions of the children can be described in relation to each other or to the parent.
Note that you cannot have a circular dependency between the size of the RelativeLayout and the position of its children. For example, you cannot have a RelativeLayout whose height is set to WRAP_CONTENT and a child set to ALIGN_PARENT_BOTTOM
Which is exactly your case. RelativeLayout can not do that.
这篇关于RelativeLayout的正在全屏的WRAP_CONTENT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!