在 ImageView 上放置一个按钮 [英] Put a button over an ImageView

查看:21
本文介绍了在 ImageView 上放置一个按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Android 新手.

I'm newbie in Android.

我想知道是否可以在 ImageView 上放置一个按钮或其他组件.我尝试将图像设置为 LinearLayout 的背景图像,但是当我在横向和纵向模式之间切换时,图像部分会改变.

I would like to know if it's possible to put a button or another component over an ImageView. I've tried setting the image as a background image of a LinearLayout, but when I change between landscape and portrait mode, the image porportions are changed.

非常感谢.

推荐答案

不要将图像作为背景,您无法控制图像的缩放方式.相反,创建一个 RelativeLayout,并将 ImageView 作为其中一个子项,您可以将任何东西(按钮等)作为其他 RelativeLayout 子项.

Don't put the image as a background, you don't have any control on how the image is scaled. Instead, create a RelativeLayout, and put an ImageView as one of the child, and you can place anything (buttons etc) as other RelativeLayout children.

<RelativeLayout ...>
    <ImageView (your image) ...>
    <Button (the button you want) ... />
</RelativeLayout>

这篇关于在 ImageView 上放置一个按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆