1

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.

4

1 回答 1

1

这是因为您对高度和 with 进行了硬编码。将它们设置为 fill_parent ,然后它将适合边距。

于 2010-11-16T18:33:53.343 回答