7

我有一个带有ImageView背景部分的启动画面。无论我是否允许缩放我的位图(我这样做),图像质量都很糟糕。我认为它会降低颜色深度。我已经环顾四周了,一个建议是将我的图像放入raw而不是,drawable但这也无济于事。这是一个屏幕截图:

在此处输入图像描述

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

编辑:我没有以编程方式应用此位图,因此没有相关的 Java 代码。这是此活动的 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);,这产生了明显的差异,但条带仍然存在。是我用作背景的图像。

4

8 回答 8

8

条带主要发生在图像的纵横比受到干扰时。

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

  1. 制作你的形象.9.png。在这种情况下,它会自动修复任何拉伸并处理条带。

  2. 对您的图像应用表面抖动,这可能会防止任何不寻常的条带。

    <bitmap
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:src="@drawable/b1"
        android:tileMode="repeat"
        android:dither="true" />
    
于 2013-04-08T05:52:54.237 回答
2

您的图像尺寸是多少?什么是设备?我怀疑图像大小与显示器的大小不匹配,并且它位于错误的资源可绘制文件夹中。图像看起来很缩放。这些文章应该可以帮助您选择不同屏幕的图像分辨率和资源文件夹。

http://developer.android.com/guide/practices/screens_support.html

http://developer.android.com/training/multiscreen/index.html

于 2013-04-04T11:49:18.377 回答
2

您必须设置窗口颜色格式。在你的活动中放这样的东西:

getWindow().setFormat(PixelFormat.RGBA_8888);
于 2013-04-04T11:54:25.097 回答
1

我猜图像的大小小于显示图像的区域。因此,可能是图像放大并降低了质量。

What you can try is:

1. Either put the image of similar dimension 
2. use 9 patch image ( good idea )
于 2013-04-10T08:59:09.977 回答
1

您需要将图像调整为不同的大小,并将它们放入各自的可绘制文件夹中res/

于 2013-04-10T10:59:12.903 回答
0

尝试抗锯齿,这可能会解决您的问题。

使用以下 xml 创建一个可绘制的位图。

<bitmap
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/background"
    android:antialias="true"
    android:dither="true"  />
于 2013-04-09T14:32:54.673 回答
0

您正在做的是在 xml 中设置图像,这更多地取决于该图像分辨率支持的内容。

每个支持的多个设备的密度都有多个文件夹,将您的图像放在某个合适的 dpi 文件夹中。

请参阅此链接http://developer.android.com/guide/practices/screens_support.html

查看相同的应用程序图标如何在不同文件夹中表现不同

不支持不同密度的示例应用程序,如低、中和高密度屏幕上所示

不支持不同密度的示例应用程序,如低、中和高密度屏幕上所示。

在此处输入图像描述

对不同密度有良好支持的示例应用程序(它与密度无关),如低、中和高密度屏幕上所示。

于 2013-04-12T13:17:01.497 回答
0

只需通过使图像成为背景图像来调整它。这是一个示例代码

   <ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/your_image"
    />
于 2016-01-08T00:58:49.187 回答