【问题标题】:Android screen-size and resolutionAndroid 屏幕尺寸和分辨率
【发布时间】:2012-10-13 11:54:53
【问题描述】:

我的应用在 480x800 分辨率下完美运行。如果我保持 480x800 分辨率但将屏幕尺寸更改为例如 2.7 英寸、3.7 英寸或 5.4 英寸,它仍然是完美的。但是,当我将分辨率更改为例如 640x1066 时,所有的 ImageButton 都太小了,并且在所有屏幕尺寸中都位于错误的位置......我已经在所有四个文件夹(drawable-l、m、h、xh)中创建了 ImageButtons 但仍然是按钮的大小不正确..

<ImageButton
android:id="@+id/ib1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginTop="433dp"
android:background="@drawable/imagebutton1" />

<ImageButton
android:id="@+id/ib2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="188dp"
android:layout_marginTop="436dp"
android:background="@drawable/imagebutton2" />

注意:我的问题不是我改变屏幕尺寸,而是我改变屏幕分辨率。

【问题讨论】:

    标签: android xml drawable resolution screen-size


    【解决方案1】:

    您使用的是 9 个补丁图像吗?

    当涉及到图像按钮之类的东西时,它们的工作要好得多,请在 Android 文档中查看它们。

    【讨论】:

      【解决方案2】:

      是的,它当然会改变。您在dp 中提供边距(左,上),这取决于分辨率。为避免此问题,您应该进行动态计算,例如动态获取屏幕高度和宽度并相应地设置边距。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-10-06
        • 2011-11-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多