簡體   English   中英

可怕的ImageView位圖質量?

[英]Horrible ImageView bitmap quality?

我有一個啟動畫面, 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); 如所建議的那樣產生了明顯的差異但是條帶仍然存在。 是我用作背景的圖像。

當圖像的縱橫比受到干擾時,主要發生條帶化。

您可以嘗試以下任何一種方法:

  1. 制作你的形象.9.png 在這種情況下,它會自動修復任何延伸並照顧條帶。

  2. 對圖像應用表面抖動,這可能會阻止任何異常的條帶。

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

你的形象有哪些尺寸? 什么是設備? 我懷疑的是圖像大小與顯示器的大小不匹配,並且它位於錯誤的資源可繪制文件夾中。 圖像看起來相當規模。 這些文章可以幫助您挑選不同屏幕的圖像分辨率和資源文件夾。

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

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

您必須設置窗口顏色格式。 在你的活動中添加如下內容:

getWindow().setFormat(PixelFormat.RGBA_8888);

我猜圖像的尺寸小於圖像顯示的區域。 因此,可能是圖像正在擴大和失去質量。

What you can try is:

1. Either put the image of similar dimension 
2. use 9 patch image ( good idea )

您需要將圖像調整為不同的大小,並將它們放在res/下的相應可繪制文件夾中

嘗試antialias這可能會解決你的問題。

使用以下xml創建一個可繪制的位圖。

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

你正在做的是在xml中設置圖像更多取決於圖像分辨率支持的內容。

每個支持的多個設備密度都有多個文件夾,將您的圖像放在一些合適的dpi文件夾中。

請參閱此鏈接http://developer.android.com/guide/practices/screens_support.html

看到相同的應用程序圖標如何在不同的文件夾中表現得很明顯

不支持不同密度的示例應用,如低,中和高密度屏幕所示

不支持不同密度的示例應用,如低,中和高密度屏幕所示。

在此輸入圖像描述

示例應用,具有對不同密度(它的密度無關)的良好支持,如低,中和高密度屏幕所示。

只需通過將圖像作為背景圖像來調整它。 這是一個示例代碼

   <ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/your_image"
    />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM