首页 文章

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

提问于
浏览
-1

我正在使用Xamarin和Visual Studio 2012来开发我的应用程序 . 我有一个主菜单屏幕,其中包含5个图像视图 . 我在资源文件夹中创建了以下文件夹:drawable-mdpi,drawable-hdpi,drawable-xhdpi和drawable-xxhdpi,我还为这些适当大小的drawable创建了4组图标 . 但是当我在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>

1 回答

  • 0

    如果您在密度无关像素(dp)中给出图标大小,则几乎所有设备都可以看到相同大小的图标 .

    从代码中您指示您的设备应仅支持mdpi,hdpi和xhdpi密度的小屏幕,普通屏幕和大屏幕 . 这与您的问题无关 .

    Nexus 4和Nexus 7都属于xhdpi类别,因此两个选择图标都形成了drawable-xhdpi文件夹 . 因此,如果您在dp中给出图标大小,那么您将在两个设备中看到相同大小的图标 .

    如果要为普通设备和大型设备创建不同大小的图标,请创建具有不同图标大小的单独布局

    res/layout
    res/layout-large
    

    文件夹

    Refereces:

相关问题