在RelativeView重叠的ImageView [英] Overlapping ImageView in RelativeView
问题描述
。如下图我的code,我已经2 ImageView的,我想重叠,但更大的是系统地下文中较小的一个,无论是安卓layout_alignParentTop设置真,我认为这会导致重叠而Android保持dislaying它们下面的另一个。
< RelativeLayout的机器人:ID =@ + ID / RelativeLayout1
机器人:layout_width =WRAP_CONTENT机器人:layout_height =WRAP_CONTENT
机器人:layout_gravity =center_vertical | CENTER_HORIZONTAL
机器人:重力=CENTER_HORIZONTAL | center_vertical>
< ImageView的机器人:ID =@ + ID / homeStars机器人:SRC =@绘制/背景
机器人:layout_height =WRAP_CONTENT的android:layout_width =FILL_PARENT机器人:scaleType =centerInside
机器人:layout_centerHorizontal =真正的机器人:layout_centerVertical =真正的机器人:layout_alignParentTop =真
/>
< ImageView的机器人:ID =@ + ID / homeLogo机器人:SRC =@绘制/标志
机器人:layout_height =WRAP_CONTENT的android:layout_width =220dip
机器人:layout_alignParentTop =真正的机器人:layout_centerHorizontal =真
机器人:paddingTop =2DIP/>
< / RelativeLayout的>
诺塔1:我不希望第一个被设置为相对于图的背景做。
诺塔2:我要补充,这相对布局是滚动型里面放
< RelativeLayout的
机器人:ID =@ + ID / RelativeLayout1
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT> < ImageView的
机器人:ID =@ + ID / homeStars
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:scaleType =centerInside
机器人:SRC =@绘制/背景/> < ImageView的
机器人:ID =@ + ID / homeLogo
机器人:layout_width =220dip
机器人:layout_height =WRAP_CONTENT
机器人:paddingTop =2DIP
机器人:SRC =@绘制/标志/>< / RelativeLayout的>
我删除了所有的你不同layout_ *标签和它工作正常。当然,所有的孩子将在一个 RelativeLayout的
左上角自己的定位相互重叠。你是多余的标签被混淆不仅是我,但有可能的解析器。复制粘贴上述code和更改增量下一次! :)
As my code below shows, I've two ImageView that I would like to overlap but the bigger is systematically put below the smaller one, both is android:layout_alignParentTop set "true", I thought that would lead to an overlapping but Android keeps dislaying them one below the other.
<RelativeLayout android:id="@+id/RelativeLayout1"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center_horizontal|center_vertical">
<ImageView android:id="@+id/homeStars" android:src="@drawable/background"
android:layout_height="wrap_content" android:layout_width="fill_parent" android:scaleType="centerInside"
android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:layout_alignParentTop="true"
/>
<ImageView android:id="@+id/homeLogo" android:src="@drawable/logo"
android:layout_height="wrap_content" android:layout_width="220dip"
android:layout_alignParentTop="true" android:layout_centerHorizontal="true"
android:paddingTop="2dip" />
</RelativeLayout>
Nota 1 : I do not want the first one to be set as a background of the relative view. Nota 2 : I should add that this Relative Layout is put inside a ScrollView.
<RelativeLayout
android:id="@+id/RelativeLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/homeStars"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="centerInside"
android:src="@drawable/background" />
<ImageView
android:id="@+id/homeLogo"
android:layout_width="220dip"
android:layout_height="wrap_content"
android:paddingTop="2dip"
android:src="@drawable/logo" />
</RelativeLayout>
I removed all of you're different layout_* tags and it works fine. Naturally all children will overlap each other by positioning themselves at the top left in a RelativeLayout
. You're extra tags were confusing not only me but likely the parser. Copy paste the above code and make changes incrementally next time! :)
这篇关于在RelativeView重叠的ImageView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!