我有一个带有背景 PNG 的 RelativeLayout。背景PNG中有一个标题。在 RelativeLayout 中,我将小部件放置在此标题中。
当它扩展到更大的设备时,问题就开始了:背景 PNG 中的标题拉伸,导致小部件在标题中的位置太高。因为我在“dp”中指定了我的相对布局定位,所以我希望小部件能够根据背景图像的缩放比例重新定位并自动放置到位。
这是我的 RelativeLayout 的简化版本:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:paddingBottom="26dp"
android:paddingLeft="12dp"
android:background="@drawable/home_bg"
android:paddingRight="12dp"
tools:context=".HomeActivity" >
<TextView
android:id="@+id/welcome_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="142dp"
android:text="@string/home_11"
android:textColor="@color/tile_points_white"
android:textSize="20sp" />
</RelativeLayout>
我知道我可以在 9 补丁背景 PNG 中修复标题高度(这就是我现在所做的),但我宁愿让标题也垂直缩放。
如何指定我的小部件应与背景 PNG 的缩放成比例地重新定位?
干杯,安德烈