2012-03-12 59 views
1

我有以下主佈局代碼:如何製作透明佈局?

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:id="@+id/layout" 
    android:gravity="center" 
    android:background="#00000000" 
    android:orientation="vertical" > 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="200dp" 
     android:layout_height="200dp" 
     android:background="#FFFFFF" /> 

</LinearLayout> 

我需要的是的LinearLayout將是透明的。我認爲我可以在背景屬性中使用alpha設置,但它不起作用。請告訴我 - 我需要我的應用程序將是空的,並在屏幕中心有一個白色矩形。

回答

1

您希望活動是透明的嗎? 嘗試使用您的活動標籤這個主題(manifest文件):@android:style/Theme.Translucent

對於其他可能的方式,即兒童主題請參閱下面的答案:

Activity should be transparent, but has black background

How do I create a transparent Activity on Android?

how to make activities transparent

+0

謝謝。你已經度過了我的一天。 – user1166635 2012-03-12 09:12:18

+0

沒問題,很樂意幫忙。 – 2012-03-12 09:13:36

0

在xml文件中使用以下行:

<Linearlayout android:background="@android:color/transparent"/> 
+0

我試過但不工作。 :( – Noby 2012-06-08 18:20:25