Valeriy
Valeriy

Reputation: 201

How supporting screens with non-standart DPI

I have an application without tablet support using this method https://stackoverflow.com/a/41224771/7609373, but this implementation does not support devices with non-standard DPI, such as 408, which are found on Huawei devices. But google play is against using 408 and 410 in the manifest. How can such devices be supported?

Upvotes: 0

Views: 89

Answers (1)

RajeshVijayakumar
RajeshVijayakumar

Reputation: 10630

First of all, You need to understand the scaling factor in android, Below link will be useful for you Android doc Link

Let say in your case, you want to support dpi range between 320+ to 480 dpi. Your support for device falls into the following range

xlarge XHDPI and normal XXHDPI resolution

I will prefer the following way..

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...

Upvotes: 1

Related Questions