2

android/eclipseで透明なPNGを透明に見せることに問題があります。

私はこれを持っています:

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

XMLグラフィックレイアウトでは、画像ビューでこの画像を使用すると、画像の透明度が黒で表示されます。

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

次の画像を使用すると、透明度が正しく表示されます。

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

Windowsデスクトップの壁紙の前に透明な画像アイコンが表示されます。また、画像を手作業で確認して、両方が透明であることを確認することもできます。

これはバグですか、それとも何が起こっているのですか?Eclipse/androidに表示される透明なPNGを作成できません。だから私はあなたに見せるためにウェブから2番目の画像を取りました...

編集:私はたくさんの画像を透明にする必要があります、現在私はirfanviewを使用しています。他にどのようなプログラムが適していますか?

EDIT2:

注意すべきもう1つのことは私が置くことです

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>
4

3 に答える 3

1

画像が透明に表示されている可能性がありますが、実際にはレイアウトの一部が黒い背景であり、画像の一部が透明であるため、背景が透けて見えます。

の背景をImageView特定の色に設定してみて、変化するかどうかを確認してください。

この行を xml のImageViewセクションに追加するだけです。

android:background="#FF0000"(赤) または他の 16 進数値を入力して、それが透けて見えるかどうかを確認します。

xml ファイル全体を投稿できますか?

編集: Paint.net を使用して画像を操作します。これは無料で、透明な背景を作成するのに適しています。

于 2013-01-19T19:04:09.027 に答える
0

xml レイアウトの画像ビューの背景に null を使用してみてください。

android:background="@null"
于 2014-08-08T10:11:09.587 に答える
0

OK IrfanView のバグであることを確認しました。

ただし、IrfanViewプラグインpngout.dll(これが存在することに感謝します)を使用してpngを保存すると(保存ダイアログでプラグインを使用するかどうかを選択できます)、pngは「破損」しません。

誰が考えただろうか?

編集: ここからプラグインをダウンロードしてください http://www.irfanview.com/plugins.htm (これらの zip ファイルの 1 つ)

edit2: ok は日食のバグである可能性もあります。PNG非標準準拠を読み書きするプログラムは何でも、つまり

于 2013-01-19T20:02:29.210 に答える