Android mipmap,图像密度?

标签 android android-studio android-ui android-resources

您现在可能知道,当您使用 IDE 创建 Assets 时,android studio 1.1 在 mipmap-xxx 文件夹而不是 drawable-xxx 文件夹中创建新的图像 Assets 。我在这里面临的问题是,当我在我的 xml 文件中使用这些图像时,android 会将它们作为“图标”,因此当我尝试以适当的大小显示它们时,我会松散密度。 例如使用此代码:

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="32dp"
        android:src="@mipmap/ic_login_logo" />

我确实得到了正确的密度但错误的大小,如果我这样做:

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:layout_marginTop="32dp"
        android:src="@mipmap/ic_login_logo" />

我得到了正确的尺寸...但错误的密度。 我不是 UI/UX 专业人士,之前使用可绘制对象时我也没有遇到过这个问题。 我什至无法从 IDE 将我的资源添加到 drawable-xxx 文件夹中: enter image description here

有解决办法吗?谢谢。

最佳答案

我只是在搜索 mipmap 文件夹的用法。根据this answer &这个Google blogspot :

It’s best practice to place your app icons in mipmap- folders (not the drawable- folders) because they are used at resolutions different from the device’s current density.

还有 this answer有引用文献的详细解释。

根据我阅读这些答案的理解,我们将图标放在 mipmap-xxx 文件夹中,并将我们将使用的可绘制对象放在 drawable-xxx 文件夹中,就像以前一样。

关于Android mipmap,图像密度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28738020/

相关文章:

android - 媒体查询适用于桌面但不适用于移动设备

android - 是否有用于删除警报的 Android API

android - fragment 不会在视觉上被删除

安卓用户界面示例

android - 在屏幕的任意位置显示 AlertDialog

android - 创建 Intent 选择器而不启动所选 Intent

android - 不同进程中的 OnPreferenceChangeListener - 共享偏好数据

android - 当我运行 android studio 2.2.3 时,会显示这些消息并且无法运行我的项目。我该如何解决?

android - 尝试在空对象引用上调用虚拟方法 'void android.support.v7.app.ActionBar.setDisplayHomeAsUpEnabled(boolean)'

java - 插件 Android 支持异常