2015-05-14 112 views
0

我在我的應用程序中使用圖像,我知道它是透明背景PNG。在android工作室它prerenders它正確,但在虛擬機它得到白色背景..任何人有任何想法我做錯了什麼?Android透明度不適用於PNG

My xml snippet;

<ImageView 
    android:id="@+id/fullscreen_content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:scaleType="centerInside" 
    android:background="@android:color/transparent" 
    android:adjustViewBounds="true" 
    android:gravity="center" 
    android:src="@drawable/jlogo2" 
/> 

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" 
    android:layout_height="match_parent" android:background="#ff19cc00" 
    tools:context=".FullscreenActivity"> 

    <!-- The primary full-screen view. This can be replaced with whatever view 
     is needed to present your content, e.g. VideoView, SurfaceView, 
     TextureView, etc. --> 


    <ImageView 
     android:id="@+id/fullscreen_content" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:scaleType="centerInside" 
     android:background="@android:color/transparent" 
     android:adjustViewBounds="true" 
     android:gravity="center" 
     android:src="@drawable/jlogo2" 
    /> 


    <!-- This FrameLayout insets its children based on system windows using 
     android:fitsSystemWindows. --> 
    <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" 
     android:fitsSystemWindows="true"> 

     <LinearLayout android:id="@+id/fullscreen_content_controls" style="?metaButtonBarStyle" 
      android:layout_width="match_parent" android:layout_height="wrap_content" 
      android:layout_gravity="bottom|center_horizontal" 
      android:background="@color/black_overlay" android:orientation="horizontal" 
      tools:ignore="UselessParent"> 


      <Button android:id="@+id/dummy_button" style="?metaButtonBarButtonStyle" 
       android:layout_width="0dp" android:layout_height="wrap_content" 
       android:layout_weight="1" android:text="@string/dummy_button" /> 

     </LinearLayout> 
    </FrameLayout> 

</FrameLayout> 
+1

檢查父視圖,可能是白色背景 –

+0

我的繼承人充分活動的XML – NicklasN

+0

@android:彩色/透明可能會被不同風格覆蓋,請嘗試在android studio w中查看它ith相同版本的虛擬機,或添加顏色值#00ffffff並使用它 –

回答

0

嘗試

android:background="@null" 

在您的ImageView

+0

我試過了,它只是得到黑色的地方將形象:: – NicklasN

+0

試着做到這一點具有 」 – Jikiwiki

+0

這很有效,但只要我將其更改爲我的PNG,它就會再次獲得白色背景。我已經在Photoshop中檢查了兩次關於PNG的背景,並且所有PS都關注它的透明度。 – NicklasN