2013-01-19 28 views
2

我在使用透明PNG在android/eclipse中看起來有些問題。Android(日食)PNG透明度顯示爲黑色(帶圖片示例)

我有這樣的:

<ImageView 
     android:id="@+id/someid" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/theimage" /> 

的XML圖形佈局中的ImageView使用該圖像時顯示圖像的透明度爲黑色:

http://s7.directupload.net/file/d/3140/ehqd3yhm_png.htm

如果我用下面的圖像的透明度顯示正常:

http://s7.directupload.net/file/d/3140/dc5aco6n_png.htm

您將看到圖像圖標作爲Windows桌面壁紙的透明盈方。您也可以手動驗證圖像,看看它們是否都是透明的。

這是一個錯誤還是發生了什麼?我無法創建將在eclipse/android中顯示的透明PNG。所以我從網上的第二張圖片給你看...

編輯:我需要使很多圖像透明,目前我使用irfanview。還有什麼其他計劃適合?

EDIT2:要注意

一個附加的東西是我把

android:theme="@android:style/Theme.Light" 

到我的表現,因爲我想白色的主題,而不是黑色。不知道這是否有任何意義。

整個XML文件如下:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" > 

    <ImageView 
     android:id="@+id/beleg_imagegesperrt" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="10dp" 
     android:src="@drawable/ic_schloss_zu"/> 

    <!-- this is the imageview I test with, i added android:background="#FF0000" but does not help --> 
    <ImageView 
     android:id="@+id/beleg_imageabgeschlossen" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:onClick="onClickBarauslagen" 
     android:src="@drawable/dddd" 
     /> 

    <ImageView 
     android:id="@+id/beleg_imageeinsatzberichtvorhanden" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="10dp" 
     android:src="@drawable/ic_notizbuch_unselected" /> 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <TextView 
      android:id="@+id/beleg_textbelegid" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/textbelegid" /> 

     <TextView 
      android:id="@+id/beleg_belegid" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:paddingLeft="@dimen/abstand_liste" 
      android:text="@string/belegid" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <TextView 
      android:id="@+id/beleg_textbelegvonbis" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/textbelegvonbis" /> 

     <TextView 
      android:id="@+id/beleg_belegvon" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:paddingLeft="@dimen/abstand_liste" 
      android:text="@string/belegvon" /> 

     <TextView 
      android:id="@+id/beleg_belegbis" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:paddingLeft="@dimen/abstand_liste" 
      android:text="@string/belegbis" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <TextView 
      android:id="@+id/beleg_textbelegabgeschlossen" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/textbelegabgeschlossen" /> 

     <TextView 
      android:id="@+id/beleg_belegabgeschlossen" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:paddingLeft="@dimen/abstand_liste" 
      android:text="@string/belegabgeschlossen" /> 

     <TextView 
      android:id="@+id/beleg_textbeleggesperrt" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/textbeleggesperrt" /> 

     <TextView 
      android:id="@+id/beleg_beleggesperrt" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:paddingLeft="@dimen/abstand_liste" 
      android:text="@string/beleggesperrt" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <TextView 
      android:id="@+id/beleg_textbelegsummestunden" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/textbelegsummestunden" /> 

     <TextView 
      android:id="@+id/beleg_belegsummestunden" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:paddingLeft="@dimen/abstand_liste" 
      android:text="@string/belegsummestunden" /> 
    </LinearLayout> 

</LinearLayout> 
+1

Photoshop。或者,如果你沒有那個免費的GIMP。 (http://www.gimp.org) – pumpkee

+0

爲了讓您知道,我嘗試了您提供的第一張圖片,並在我的SGS II上正常工作。 – harism

+0

嗯,它與android:theme =「@ android:style/Theme.Light」有什麼關係,我偶然將它放入我的清單文件中?我能做些什麼來解決這個問題? – cdbeelala89

回答

0

確定 Cofirmed它是一個IrfanView錯誤。

如果我使用的IrfanView插件pngout.dll(感謝上帝存在的話),但是保存爲PNG(可在選擇保存對話框是否使用插件),該PNG圖像不是「破壞」。

誰會想到?

編輯:這裏http://www.irfanview.com/plugins.htm downbload插件(在那些zip文件之一)

EDIT2:好的也可能是日食的一個bug。無論程序如何寫入或讀取PNG非標準符合,即

1

很可能你的圖像顯示爲透明的,但佈局的某些部分其實是一個黑色的背景,因爲圖像的部分透明,背景是透徹的。

嘗試將ImageView的背景設置爲某種顏色並查看是否更改。

您可以在此行只是添加到您的xml在ImageView部分:

android:background="#FF0000"(紅色)或看到一些其他的十六進制值,如果顯示出來。

你能發佈整個xml文件嗎?

編輯:我使用Paint.net處理圖像,它是免費的,適用於創建透明背景。

+0

嗨,謝謝,我用xml代碼更新了我的帖子。還要注意,我的清單中有android:theme =「@ android:style/Theme.Light」(不知道這是否與問題有關,因爲默認主題也是黑色的...)。不幸的是你的建議無濟於事。將paint.net做批量轉換爲透明PNG?在irfanview中,我可以點擊快速連續點擊透明顏色,並處理很多像這樣的圖像。 – cdbeelala89

+0

更新:我現在也嘗試了第二張圖片。這裏紅色顯示在PNG的透明區域中。只是沒有第一張圖片:(我的意思是它們都是透明的PNG圖像,我沒有明白。 – cdbeelala89

+0

paint.net的作品,只是測試它,但我需要做透明PNG和很多...這是不會很有趣 – cdbeelala89

0

嘗試在xml佈局中將圖像視圖的背景用於null。

android:background="@null"