2014-09-05 52 views
0

我有一個文字瀏覽和圖像瀏覽的relativeLayout。覆蓋RelativeLayout不適用於佈局中的圖像

當我覆蓋的佈局是這樣的:

color = new ColorDrawable(Color.argb(80, 0, 0, 0)); 
     mMainLayout.setBackground(color); 

佈局有一些較暗的顏色。

除了圖片視圖,它們保持不變。所以我想我試試

statsImage.setImageAlpha(255); 

但仍然圖像保持不變。

有人可以幫助我嗎?

有人還解釋了爲什麼imageview沒有得到覆蓋?這是佈局的孩子:

<ImageView 
     android:id="@+id/headerImage" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/shape_profile_pic" /> 


    <ImageView 
     android:id="@+id/statsImage" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_marginTop="70dp" 
     android:background="@drawable/shape_stats" /> 
</RelativeLayout> 

編輯:

現在我得到這個:

<RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

    <View 
     android:id="@+id/overlayMainView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     /> 

我設置背景顏色是這樣的:

color = new ColorDrawable(Color.argb(80, 0, 0, 0)); 
mMainViewOverlay.setBackground(color); 
+0

mMainLayout.setBackground(color);設置,嗯,背景播種如何背景可以覆蓋前景中的東西?你需要的是一個完整覆蓋你的相對佈局的視圖 – pskink 2014-09-05 11:53:53

+0

所以我只需要添加一個圍繞一切,並設置它的背景顏色? – user1007522 2014-09-05 11:54:41

+0

我無法表達它更好,是的,只是使用普通的視圖,並將其背景色設置爲半透明 – pskink 2014-09-05 11:57:32

回答

1

找到解決方案。您需要使用我的編輯中的代碼。您只需要在相對佈局的末尾添加「黑色」視圖,否則您在視圖之後添加的所有內容都置於視圖之上。