【问题标题】:Pre-Scaling and Supporting Different Size Screens Android预缩放并支持不同尺寸的Android屏幕
【发布时间】:2012-05-22 17:50:57
【问题描述】:

我正在阅读http://developer.android.com/guide/practices/screens_support.html 并试图了解预缩放的工作原理。

我有以下针对银河选项卡优化的布局文件:

<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativelayoutmain"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/mainmenu"
>
<ImageButton
android:id="@+id/start_button"
android:layout_marginLeft="150dip"
android:layout_marginTop ="70dip"
android:layout_width="500dip"
android:layout_height="214dip"
android:background="@drawable/startsession"
android:contentDescription="@string/descbuttonstart"
/>

我已将屏幕图像放在 drawable-ldpi 文件夹中。问题是,当我在较小的屏幕上(使用模拟器)测试应用程序时,屏幕无法正确缩放 - 按钮很大且位置不正确。

是否有可能只为所有屏幕提供一个布局文件,如果是,那么让这个文件正常工作的秘诀是什么?

谢谢。

【问题讨论】:

    标签: android screen screen-resolution


    【解决方案1】:

    不,据我所知,您不可能需要三个不同的文件夹(hdpi、mdpi、ldpi),按钮、图像等具有不同的尺寸 同样对于布局,您需要拥有三个布局文件夹(布局小、布局中、布局大)

    【讨论】:

      【解决方案2】:

      屏幕尺寸和屏幕分辨率是两个独立的东西。 ldpi 文件夹中的资源用于低分辨率且不需要小屏幕尺寸。我更喜欢的方式是为高分辨率定义资源并让它们按比例缩小。

      【讨论】:

      • 谢谢 - 所以我应该为每个屏幕尺寸设计一个单独的布局文件?
      猜你喜欢
      • 2019-06-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多