android - 糟糕的 ImageView 位图质量?

标签 android android-imageview

我有一个闪屏,其中有一个 ImageView 作为背景。不管我是否允许缩放位图(我这样做),图像质量都很糟糕。我认为它正在降低颜色深度。我已经环顾四周,一个建议是将我的图像放在 raw 而不是 drawable 中,但这也没有帮助。这是一个屏幕截图:

enter image description here

这里到底发生了什么,我该如何解决?

编辑:我没有以编程方式应用此位图,因此没有相关的 Java 代码。这是此 Activity 的 XML 代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/RelativeLayoutSplash"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:drawingCacheQuality="high"
    android:orientation="vertical"
    android:padding="@dimen/splash_padding"
    android:scrollbarAlwaysDrawVerticalTrack="true"
    tools:context=".SplashActivity" >

    <ImageView
        android:id="@+id/ImageViewBg"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:contentDescription="@string/logo_description"
        android:scaleType="centerCrop"
        android:src="@drawable/splash_bg_register" />

    <ImageView
        android:id="@+id/ImageViewLogo"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:contentDescription="@string/logo_description"
        android:maxHeight="@dimen/logo_maxheight"
        android:maxWidth="@dimen/logo_maxwidth"
        android:layout_centerVertical="true"
        android:src="@drawable/logo" />

    <TextView
        android:id="@+id/TextViewCopyright"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:text="@string/copyright"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textColor="@color/white_50"
        android:textSize="@dimen/copyright_size" />

</RelativeLayout>

编辑:我按照建议尝试了 getWindow().setFormat(PixelFormat.RGBA_8888); 这产生了明显的差异,但 strip 仍然存在。 This是我用作背景的图像。

最佳答案

strip 现象主要发生在图像的宽高比受到干扰时。

您可以尝试以下任一方法:

  1. 制作你的图片.9.png。在这种情况下,它会自动修复任何拉伸(stretch)并处理 strip 。

  2. 对您的图像应用表面抖动,这可能会防止出现任何异常 strip 。

    <bitmap
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:src="@drawable/b1"
        android:tileMode="repeat"
        android:dither="true" />
    

关于android - 糟糕的 ImageView 位图质量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15809859/

相关文章:

android - 无法解析可绘制资源

android - 数以千计的 ORMLite 原始插入在 Android 上花费几分钟

android - 滚动时 RecyclerView 项目大小发生变化

android - ScrollView 填充

Android imageview 支持 png 、 jpeg 等图像类型

android - 以编程方式将 ImageView 添加到布局

Android Facebook SDK 3.0 session 状态 "Opening"

android - 始终隐藏虚拟键盘

Android 光标崩溃

android - 扩大最大宽度的ListView中的ImageView