2012-02-01 99 views
1

我有一個要求...我想要透明的佈局(80%像這樣透明),以便背景應該可見。有沒有辦法做同樣的..?透明佈局......?

我想,(但不是working..that第二線性佈局應透明)

<?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:orientation="vertical" 
    android:background="#C0C0C0"> 



    <LinearLayout 
     android:id="@+id/linearLayout1" 
     android:layout_width="match_parent" 
     android:layout_height="60dip" 
     android:background="@drawable/style"> 

     <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/hello" /> 

    </LinearLayout> 

</LinearLayout> 

<?xml version="1.0" encoding="UTF-8"?> 
<resources> 
    <style name="YourTheme" parent="android:@Theme.Translucent"> 
      <item name="android:windowBackground">@color/background</item> 
    </style> 
</resources> 

<?xml version="1.0" encoding="UTF-8"?> 
<resources> 
    <color name="background">#55000000</color> 
</resources> 

,但它不工作。 第二條線性曲線應該是透明的。

感謝.....

+0

能否請你後你做了什麼的瞬間?和transperent意味着什麼?你想讓你的壁紙在你的半透明背景下被看到嗎? – Hiral 2012-02-01 12:21:30

+0

你正好...你有我的要求。半透明背景下可見的壁紙.. ????。 – KKC 2012-02-01 12:33:57

+0

但是,你不能爲你的xml的一部分做到這一點,你可以讓你的完整活動是transperent.please請參閱http://developer.android.com/resources/samples/ApiDemos/src/com/example/android /apis/app/TranslucentBlurActivity.html和http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/TranslucentActivity.html – Hiral 2012-02-01 12:37:58

回答

0

主題父=「機器人:@ Theme.Translucent」是正確的,但問題是改變你的佈局尺寸按要求,然後實現主題在清單文件那個活動。這應該工作。記得佈局的高度和寬度應顯式地提到

+0

使用佈局的高度和寬度,而不是填充父eg.200dip – aviz 2012-02-01 12:35:43

+0

其實我想要特定佈局的透明度而不是整個活動。例如在半透明背景下可見的線性佈局壁紙。 – KKC 2012-02-01 12:39:03

0

你好這裏是你的問題的解決方案....

您可以從00不等它FF(六十進制)

爲了獲得最大的透明度= >#00555555(這裏00代表阿爾法)

對於最小或沒有透明度=>#FF555555(這裏FF表示阿爾法)

您可以設置alpha爲您的LinearLayout是這樣的:

LinearLayout ll = (LinearLayout) findViewById(R.id.linearlayout1); 


ll.setAlpha(0.4);