开发者

ANDROID: How to fix the position of a ImageButton relative to the background?

开发者 https://www.devze.com 2023-01-25 04:02 出处:网络
How to fix the position/layout of a ImageButton/Button/ImageView relative to the background? I\'d tried something like this:

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.


It's because you hardcoded the height and with. Set them to fill_parent and it will then fit the margin.

0

精彩评论

暂无评论...
验证码 换一张
取 消