Will this work on all screen sizes?

≡放荡痞女 提交于 2020-01-03 01:58:08

问题


I've been doing lots of research lately on optimizing my app for all screen sizes. I've created 9 of every layout in order to fit every size.

Don't worry about those other two layouts that are just in the layout directory, I will make 8 more of those later

(Android view)

Some articles say to have more layouts, but of what? Am I missing something? Did I do this correctly?

I have some doubt about my screen sizes, as lots of people on the internet have different ways of targeting different devices, is this correct?

    <compatible-screens>
        <screen
            android:screenDensity="ldpi"
            android:screenSize="small" />
    <screen
        android:screenDensity="mdpi"
        android:screenSize="normal" />
    <screen
        android:screenDensity="xhdpi"
        android:screenSize="large" />
    <screen
        android:screenDensity="xhdpi"
        android:screenSize="xlarge" />
</compatible-screens>

Do I need to add more compatible screens? Because other documents have a lot more. Will my app show up on all devices, like tablets?

Is there anything I missed in order to be optimized for all devices, like tablets and phones? Must I create any new layouts or add more compatible screen permissions in the manifest?


回答1:


Use this

<supports-screens
        android:anyDensity="true"
        android:xlargeScreens="true"
        android:largeScreens="true"
        android:normalScreens="true"
        android:smallScreens="true" />

An application "supports" a given screen size if it resizes properly to fill the entire screen. Normal resizing applied by the system works well for most applications and you don't have to do any extra work to make your application work on screens larger than a handset device. However, it's often important that you optimize your application's UI for different screen sizes by providing alternative layout resources. For instance, you might want to modify the layout of an activity when it is on a tablet compared to when running on a handset device.

Please read official Document's about Declare Support for Tablet Screens & supports-screens . I hope it will helps you .

<compatible-screens>
<!-- all normal size screens -->
<screen android:screenSize="normal" android:screenDensity="mdpi" />
<screen android:screenSize="normal" android:screenDensity="hdpi" />
<screen android:screenSize="normal" android:screenDensity="xhdpi" />
<!-- all large size screens -->
<screen android:screenSize="large" android:screenDensity="mdpi" />
<screen android:screenSize="large" android:screenDensity="hdpi" />
<screen android:screenSize="large" android:screenDensity="xhdpi" />
<!-- all xlarge size screens -->
<screen android:screenSize="xlarge" android:screenDensity="mdpi" />
<screen android:screenSize="xlarge" android:screenDensity="hdpi" />
<screen android:screenSize="xlarge" android:screenDensity="xhdpi" />

Courtesy Goes to Optimizing Android manifest file for largest number of supported devices



来源:https://stackoverflow.com/questions/34308081/will-this-work-on-all-screen-sizes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!