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 - 我如何找出用户有多少未读电子邮件? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01