【发布时间】:2016-01-08 08:58:49
【问题描述】:
我有一个带有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);,这产生了明显的差异,但条带仍然存在。 This 是我用作背景的图片。
【问题讨论】:
-
发布您的代码。
-
图片大小是多少?
-
将 android:scaleType 设置为 matrix
-
不,这不能正确缩放图像。 @Arju,它高 1000 像素,宽 800 像素。