对于一个游戏,我有六个在mdpi上看起来不错的按钮。左侧4个按钮为100x100px:
如果我切换到hdpi,它看起来像这样:
xml看起来像这样(为了保持简单,我省略了除一个按钮之外的所有按钮):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gameContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.0"
android:orientation="vertical" >
<com.mydomain.mygame.game.GameSurface
android:id="@+id/gameSurface"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background_game" >
</com.mydomain.mygame.game.GameSurface>
<RelativeLayout
android:id="@+id/controlButtonContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/button_left"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="100dp"
android:contentDescription="@string/button_left"
android:background="@drawable/control_button" />
</RelativeLayout>
</FrameLayout>
<LinearLayout
android:id="@+id/emptyBar"
android:layout_width="match_parent"
android:layout_height="40dp"
android:baselineAligned="false"
android:gravity="center"
android:orientation="horizontal" >
</LinearLayout>
</LinearLayout>
这些尝试没有奏效:
我试着用
100分贝
而不是
包装内容
。我试过了
钢筋混凝土
而不是
出身背景
我也尝试了不同的方式
scaleType(缩放类型)
属性。
也许我可以在代码中计算缩放因子,但我无法想象这是正确的方法。为什么它不能自动缩放,因为
数据处理
然后呢?那么如何在xml中配置正确的比率呢?