简体   繁体   English

Android UI 设计:多种图标尺寸适用于多种屏幕尺寸

[英]Android UI design: multiple icon sizes for multiple screen sizes

I'm using Xamarin and Visual Studio 2012 for developing my application.我正在使用 Xamarin 和 Visual Studio 2012 来开发我的应用程序。 I have a main menu screen which contains 5 image views.我有一个包含 5 个图像视图的主菜单屏幕。 I have created the following folders in the resources folder: drawable-mdpi, drawable-hdpi, drawable-xhdpi and drawable-xxhdpi and I also created 4 sets of icons for these drawables with proper sizes.我在资源文件夹中创建了以下文件夹:drawable-mdpi、drawable-hdpi、drawable-xhdpi 和 drawable-xxhdpi,我还为这些绘图创建了 4 组大小合适的图标。 But when I test my application on nexus 7, icons sizes are the same as on nexus 4. I also added these lines to manifest file:但是当我在 nexus 7 上测试我的应用程序时,图标大小与 nexus 4 上的相同。我还将这些行添加到清单文件中:

    <compatible-screens>
    <!-- all small size screens -->
    <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="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" />
</compatible-screens>

If you have given icon size in density-independent pixels (dp) you can see the icon in same size across almost all the devices.如果您以与密度无关的像素 (dp) 给出图标大小,您几乎可以在所有设备上看到相同大小的图标。

From the code you are instructing that your device should support only small, normal and large screens for mdpi, hdpi and xhdpi densities.从代码中,您指示您的设备应仅支持 mdpi、hdpi 和 xhdpi 密度的小屏幕、普通屏幕和大屏幕。 Which is not relevant to your question.这与您的问题无关。

Nexus 4 and Nexus 7 both fall under the category xhdpi, So both pick icons form drawable-xhdpi folder. Nexus 4 和 Nexus 7 都属于 xhdpi 类别,所以两个选择图标形成 drawable-xhdpi 文件夹。 So yo will see the icons same size in both devices if you have given icon size in dp.因此,如果您以 dp 为单位给出了图标大小,那么您将在两个设备中看到相同大小的图标。

If you want to create different sizes of icons for normal and large devices, create separate layouts which has different icon sizes in如果要为普通设备和大型设备创建不同大小的图标,请创建具有不同图标大小的单独布局

res/layout
res/layout-large

folders文件夹

Refereces:参考资料:

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

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