【问题标题】:Image is shown as blurred in ImageView while using mipmap resource directory使用 mipmap 资源目录时,图像在 ImageView 中显示为模糊
【发布时间】:2018-08-05 07:24:02
【问题描述】:

在使用 android:src="@mipmap/stunner 在 Android Studio 的 ImageView 中加载图像时,我的图像变得模糊,什么怎么办??请帮忙...

我的代码如下:

<ImageView
    android:src="@mipmap/stunner"
    android:adjustViewBounds="true"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="2dp"/>

【问题讨论】:

  • 请将 stunner 图像放入 drawable 文件夹并像 android:background="@drawable/stunner" 一样使用并检查
  • 如果你这样做呢? android:background="@mipmap/stunner"
  • 将 mipmap 用于启动器图标和可绘制对象中的其他图像的良好做法
  • @prasad_21 你需要多个密度的stunner 图像并将它们添加到具有各自密度的drawable文件夹中
  • 谢谢大家,android:src="@drawable/stunner" 解决了我的问题

标签: android android-studio layout android-imageview android-drawable


【解决方案1】:

请将其用作可绘制对象,而不是将其用作 mipmap。 Mipmap 用于应用程序图标,但不用于可绘制对象

这里是drawable的代码和输出

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/archive_task_open_btn"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:visibility="visible">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="2dp"
        android:adjustViewBounds="true"
        android:src="@drawable/bg" />
</FrameLayout>

【讨论】:

    猜你喜欢
    • 2016-03-06
    • 1970-01-01
    • 2020-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-01
    • 1970-01-01
    相关资源
    最近更新 更多