0
我花了最後幾天嘗試進行佈局。Android小部件相對佈局
他們的佈局看起來不錯,我的手機與480x800的屏幕,但是我的手機與540x960屏幕搞砸了。
我用dp期望它可以通過密度進行縮放。
什麼問題?
這是我的佈局xml代碼。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="15dip"
android:background="@drawable/gshock5">
<TextView
android:id="@+id/widgetday"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="50dip"
android:layout_marginTop="95sp"
android:layout_centerInParent="true"
android:text="DAY"
android:textColor="#003300"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold"/>
<TextView
android:id="@+id/widget1label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/widgetday"
android:layout_centerHorizontal="true"
android:clickable="true"
android:textColor="#003300"
android:text="Error"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="210dip">
<Button android:text="Click Me!"
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</RelativeLayout>
</RelativeLayout>
密度真的是唯一的區別嗎?如果兩個設備的分辨率*和*屏幕尺寸不同,那麼單獨放置就不會使它們顯得平等。 – Ixx
btw你正在使用sp的widgetday layout_marginTop。據我所知,這隻用於文本大小...但這不應該與您的問題有關。 – Ixx
發佈此佈局的「好」和「壞」版本的屏幕截圖可能很有用 –