我正在android中测试多dpi,布局xml文件看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@drawable/new_album_bg">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/hello" />
<RelativeLayout android:gravity="center"
android:paddingTop="400dip" android:layout_width="fill_parent"
android:layout_height="wrap_content">
<EditText android:background="@drawable/name_text_bg"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:gravity="center" />
</RelativeLayout>
</RelativeLayout>
当我在 480x800 mdpi(160) 模拟器(缩放到 7 英寸)上运行它时,它工作正常,但在 480x800 hdpi 模拟器上,它将 EditText 填充到屏幕底部附近,接近 600 像素,是 400dip x 240 / 160 ? 即使我将其缩放到 4 英寸,它似乎也与屏幕尺寸没有区别。如何让padding在不同的屏幕密度下工作?非常感谢!