ANDROID:如何固定 ImageButton 相对于背景的位置?
如何固定 ImageButton/Button/ImageView 相对于背景的位置/布局?
我尝试过这样的操作:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background_img"
>
<ImageButton
android:id="@+id/btn1"
android:layout_width="52dip"
android:layout_height="52dip"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="87dip"
android:background="@drawable/btn1"
/>
</RelativeLayout>
当我更改显示分辨率时,background_img 会拉伸以覆盖新区域,但 ImageButton 不会按比例缩放并且不会按比例尊重底部边距。
How to fix the position/layout of a ImageButton/Button/ImageView relative to the background?
I'd tried something like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background_img"
>
<ImageButton
android:id="@+id/btn1"
android:layout_width="52dip"
android:layout_height="52dip"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="87dip"
android:background="@drawable/btn1"
/>
</RelativeLayout>
When I change the display resolution, the background_img stretch to cover the new area, but the ImageButton doesn't streetch and doesn't respect the bottom margin proportionately.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是因为您对高度和高度进行了硬编码。将它们设置为 fill_parent,然后它将适合边距。
It's because you hardcoded the height and with. Set them to fill_parent and it will then fit the margin.