2012-03-12 88 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