2017-09-02 53 views
0

我想用疊加背景圖像頂部的線性佈局(像Photoshop一樣的混合模式)。用背景圖像疊加線性佈局

我無法解決它。

這是梯度圖像應該被用來作爲應用背景:

enter image description here

這就是我想覆蓋背景圖像:

enter image description here

請幫我示例代碼或指向良好教程的鏈接。

+0

您是否曾嘗試在您的父級佈局中將其作爲['android:foreground'](https://developer.android.com/reference/android/view/View.html#attr_android:foreground)屬性應用? – PPartisan

+0

是的,我想應用android:foreground屬性,但它不能解決它.. @PPartisan –

+0

看來你需要玩上層的透明度。保持你的背景圖像爲可繪製的,並將其分配給你的背景層或使用和圖像,它允許你一些技巧來裁剪和縮放它。 –

回答

0
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:background="@color/blue_600" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
tools:context=".UI.Activity.HomeActivity"> 


<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:orientation="vertical" 
     android:layout_marginTop="10dp" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp" 
     android:layout_height="wrap_content"> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:background="#54e5e5e5" 
      android:layout_height="200dp"> 

     </RelativeLayout> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:background="#54e5e5e5" 
      android:layout_marginTop="10dp" 
      android:layout_height="200dp"> 

     </RelativeLayout> 
    </LinearLayout> 

,如果你願意,你可以使用滾動視圖。