简体   繁体   English

适合所有屏幕尺寸

[英]Fit to all screen sizes

Am I doing it right? 我做对了吗? I'm trying to make my project that can be used in all different screen sizes, because from the beginning of time I'm creating it using API 17(Nexus One) 我正在尝试制作可在所有不同屏幕尺寸下使用的项目,因为从一开始我就使用API​​ 17(Nexus One)创建了该项目

<supports-screens
        android:smallScreens="true"
        android:normalScreens="true"
        android:largeScreens="true"
        android:xlargeScreens="true"
        android:anyDensity="true" />
    <application
        android:allowBackup="true"
        android:icon="@drawable/fitnessku"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:theme="@style/AppTheme" >
        <compatible-screens>
            <!-- all small size screens -->
            <screen android:screenSize="small" android:screenDensity="ldpi" />
            <screen android:screenSize="small" android:screenDensity="mdpi" />
            <screen android:screenSize="small" android:screenDensity="hdpi" />
            <screen android:screenSize="small" android:screenDensity="xhdpi" />
            <!-- all normal size screens -->
            <screen android:screenSize="normal" android:screenDensity="ldpi" />
            <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="ldpi" />
            <screen android:screenSize="large" android:screenDensity="mdpi" />
            <screen android:screenSize="large" android:screenDensity="hdpi" />
            <screen android:screenSize="large" android:screenDensity="xhdpi" />
        </compatible-screens>

You need to create directory for each layout . 您需要为每个layout创建目录。 add these directories to your layout folder to support multiple screen sizes. 将这些目录添加到layout文件夹以支持多种屏幕尺寸。

  • layout-small
  • layout-normal
  • layout-large
  • layout-xlarge
  • layout-xxlarge

Don't forget to declare it on manifest file. 不要忘记在manifest文件中声明它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM