简体   繁体   English

布局顶部的图像

[英]Image on top of a layout

在此处输入图片说明

I need to display an image on top of layout just like the one displayed in the link above. 我需要在布局顶部显示一张图片,就像上面链接中显示的一样。 Can anyone please help. 谁能帮忙。

Make the top level container a RelativeLayout , and add the rectangle viewgroup as a child. 将顶级容器设为RelativeLayout ,并将矩形视图组添加为子级。

To show the image in that specific position, make it center_horizontally , align _top with the rectangle, and give it a negative top margin ( margin_top= -halfOfImageHeight/2 ) 要在该特定位置显示图像,请将其居中居中将_top与矩形对齐 ,并给其负的上边缘空白(margin_top = -halfOfImageHeight / 2)

I recommend you relative layout to easily place the image where you want. 我建议您使用相对布局,以轻松地将图像放置在所需位置。

Older versions of Android uses xml entities order to manage elements elevation. 较旧的Android版本使用xml实体命令来管理元素提升。 This means you just have to put the image after the layout in your xml file. 这意味着您只需要将图像放置在xml文件中的布局之后即可。

In newer Android versions, there's an elevation attribute : http://developer.android.com/reference/android/view/View.html#attr_android:elevation 在较新的Android版本中,有一个height属性: http : //developer.android.com/reference/android/view/View.html#attr_android :elevation

Please post you xml code for more details. 请向您发布xml代码以获取更多详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM