【问题标题】:How supporting screens with non-standart DPI如何支持非标准 DPI 的屏幕
【发布时间】:2019-06-20 08:00:52
【问题描述】:

我有一个不支持平板电脑的应用程序使用这种方法https://stackoverflow.com/a/41224771/7609373,但是这种实现不支持具有非标准DPI的设备,例如华为设备上的408。但 google play 反对在清单中使用 408 和 410。如何支持此类设备?

【问题讨论】:

标签: android google-play android-manifest


【解决方案1】:

首先,你需要了解android中的缩放因子, 以下链接将对您有用 Android doc Link

假设在您的情况下,您希望支持 320+ 到 480 dpi 之间的 dpi 范围。您对设备的支持属于以下范围

xlarge XHDPI and normal XXHDPI resolution

我会更喜欢以下方式..

1) For every imageview, I will have fixed width and height in dp values
   ex: width=60dp && height = 60dp.

2) LayoutContainer width and height ideally you need to use match_parent and  wrap_content.

3) I will place drawable in XHDPI and XXHDPI only.
   drawable-xhdpi
   drawable-xxhdpi

4) I will create and place layouts in 
     layout-xhdpi-xlarge-port
     layout-xxhdpi-port

5) Try to use dimens.xml where dimensions such as dp and sp can be different for different resolution
     values-xhdpi-xlarge
     values-xxhdpi

6) Include screen resolution in manifest, which you need to support

   <compatible-screens>
<!-- all small size screens -->
<screen android:screenSize="small" android:screenDensity="ldpi" />
                                .
                                .
                                .
<screen android:screenSize="small" android:screenDensity="xxxhdpi" />
<!-- all normal size screens -->
<screen android:screenSize="normal" android:screenDensity="ldpi" />
                                .
                                .
                                .
<screen android:screenSize="normal" android:screenDensity="xxxhdpi" />

<!--- Adding support for Huwaei devices -->
<screen android:screenSize="large" android:screenDensity="320" />
<screen android:screenSize="large" android:screenDensity="480" />
                           or
<screen android:screenSize="large" android:screenDensity="xhdpi" />
<screen android:screenSize="normal" android:screenDensity="xxhdpi" />

</compatible-screens>
</manifest>

7) Do the last thing now in manifest file again....
 <supports-screens android:smallScreens="true"
                  android:normalScreens="true"
                  android:largeScreens="false"
                  android:xlargeScreens="false"/>

Above are some of these ways you can support non-standard dpi devices...

【讨论】:

  • 思路不错,但并没有解决问题。我需要排除大屏幕和超大屏幕尺寸(桌面设备)。并且同时支持非标显示
  • 你不相信我,好吧,我照你写的那样做,这是我添加到 GooglePlay 时收到的:在 AndroidManifest.xml 文件中发现了无效的 行: 500/408
  • 试试这个..
  • 这很可能没有帮助,目前我无法验证这样的实现。但它会增加对平板电脑的支持是事实。
猜你喜欢
  • 1970-01-01
  • 2015-12-19
  • 2016-06-09
  • 1970-01-01
  • 1970-01-01
  • 2010-11-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多