2013-02-11 42 views
0

我有以下佈局:的Android做活動的一部分,透明

<RelativeLayout> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/hello_world" /> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="200dip" 
     android:layout_alignParentBottom="true" > 
    </LinearLayout> 
</RelativeLayout> 

我要讓線性佈局完全透明的,這意味着,從活動堆棧所述先前活動的內容應該是在直線可見佈局區域。

我已經嘗試使用setAlpha(0)與線性佈局;它確實使其透明,但它顯示線性佈局區域中的活動背景色。

我也嘗試將活動的android:主題設置爲@android:style/Theme.Translucent.NoTitleBar,但這會使整個活動顯示前一活動的內容。

任何人都可以提出一種方法嗎?

謝謝。

回答

0

要明確,活動不是可見的對象。視圖是您在屏幕上看到的內容 - 特別是您看到附加到您的活動的視圖。在這種情況下,該視圖是RelativeLayout及其內容。

當您使LinearLayout透明時,它會顯示RelativeLayout的背景顏色。如果您想查看相關佈局背後的內容,請使其背景顏色透明。

<RelativeLayout android:backgrond="#00000000"> 
     ... 
     <LinearLayout android::background="#00000000"> 
      ... 
     </LinearLayout> 
</RelativeLayout> 

當然,你可能想使用一個名爲color資源,而不是「#00000000」