Put a button over an ImageView(在 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 上放置一个按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 ImageView 上放置一个按钮
基础教程推荐
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
