我有一个没有使用平板电脑支持的应用程序,使用此方法https://stackoverflow.com/a/41224771/7609373,但是此实现不支持具有非标准DPI的设备,例如408(在华为设备上找到)。但是Google Play反对在清单中使用408和410。如何支持此类设备?
答案 0 :(得分:1)
首先,您需要了解android中的比例因子, 以下链接将对您有用 Android doc Link
假设您要支持的dpi范围在320+到480 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...