如何将一个ImageView的关于在Android的另一个ImageView的顶部 [英] How to place an imageview on top of another imageview in android
问题描述
这是我的布局,我试过到目前为止没有任何成功
< RelativeLayout的的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:方向=垂直
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:背景=@色/白>
<的LinearLayout
机器人:ID =@ + ID / lltest
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:方向=横向
机器人:layout_centerHorizontal =真正的>
< ImageView的
机器人:ID =@ + ID / inside_imageview
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginTop =5dip
机器人:layout_marginBottom =5dip
机器人:SRC =@可绘制/帧/>
< / LinearLayout中>
< ImageView的
机器人:ID =@ + ID / outside_imageview
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignTop =@ ID / inside_imageview
机器人:scaleType =fitXY/>
< / RelativeLayout的>
我到底要的是有我的outside_imageview上inside_imageview与精确的高度和宽度的顶部...如何通过布局办呢?
< RelativeLayout的
的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:背景=@色/白>
< ImageView的
机器人:ID =@ + ID / inside_imageview
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginBottom =5dip
机器人:layout_marginTop =5dip
机器人:SRC =@可绘制/帧/>
< ImageView的
机器人:ID =@ + ID / outside_imageview
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignTop =@ ID / inside_imageview
机器人:layout_alignBottom =@ ID / inside_imageview
机器人:layout_alignLeft =@ ID / inside_imageview
机器人:layout_alignRight =@ ID / inside_imageview
机器人:scaleType =fitXY/>
< / RelativeLayout的>
在 layout_align【顶部|底部|左|右]
在 RelativeLayout的
用于属性来对齐根据意见它们各自的X和内缘的y值。第二个的ImageView
现在将放置在顶部,底部,左侧和右侧的第一个的ImageView
基础上,利润率。填充被忽略的对齐方式。
This is my layout which i tried so far without any success
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white">
<LinearLayout
android:id="@+id/lltest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_centerHorizontal="true">
<ImageView
android:id="@+id/inside_imageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:layout_marginBottom="5dip"
android:src="@drawable/frame"/>
</LinearLayout>
<ImageView
android:id="@+id/outside_imageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/inside_imageview"
android:scaleType="fitXY"/>
</RelativeLayout>
What i exactly want is to have my outside_imageview on top of inside_imageview with the exact height and width... How to do it through layout?
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white" >
<ImageView
android:id="@+id/inside_imageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dip"
android:layout_marginTop="5dip"
android:src="@drawable/frame" />
<ImageView
android:id="@+id/outside_imageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/inside_imageview"
android:layout_alignBottom="@id/inside_imageview"
android:layout_alignLeft="@id/inside_imageview"
android:layout_alignRight="@id/inside_imageview"
android:scaleType="fitXY" />
</RelativeLayout>
The layout_align[Top|Bottom|Left|Right]
attribute in RelativeLayout
is used to align views based on their respective x and y values within the margin. The second ImageView
will now be aligned to the top, bottom, left, and right of the first ImageView
based on the margins. Padding is ignored in the alignment.
这篇关于如何将一个ImageView的关于在Android的另一个ImageView的顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!