2016-04-07 129 views
1

我想將影子添加到Toolbar但它重疊ListView的項目。 如何讓它透明?影子重疊列表查看

Here bottom shadow overlapping list item

這裏底部陰影重疊列表項。 我使用View 9補丁繪製的陰影:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="@color/white"> 
     ... 
    </android.support.v7.widget.Toolbar> 

    <View 
     android:layout_width="match_parent" 
     android:layout_height="4dp" 
     android:background="@drawable/bottom_shadow" /> 
</LinearLayout> 

我想用透明背景

+1

怎麼樣'@android:彩色/ transparent'顏色 –

+2

如果你不想陰影,直接將其移除。使用'android:background =「@ drawable/bottom_shadow」' –

+0

顯示'bottom_shadow'的代碼 – Mangesh

回答

0

的影子,如果你不想影子,你需要刪除的android:背景=「@繪製/ bottom_shadow」

,並添加這樣的:

的android:背景= 「#8000 」

+0

不錯的嘗試,但我確實需要陰影,以便它具有透明背景 –

+0

請添加您的bottom_shadow.xml – Shellz

+0

我寫到它是9 patch png image –

0

API> 21:需要添加此工具欄上的XML ATTR

android:elevation="0dp"

API < 21:這對當前活動的主題。

<item name="android:windowContentOverlay">@null</item>


遺憾的錯誤理解。

所以這裏是一個簡單的陰影與透明背景

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <gradient android:startColor="#888" 
     android:endColor="#8fff" android:angle="-90"/> 
</shape> 
+0

我不需要刪除影子人 –

+0

你可以試試這個,另存爲bottom_shadow.xml – zayn