2016-03-11 1 views
1

J'ai deux mises en page dans mon projet android. Dans la première mise en pageComment donner dropshadow pour l'en-tête et où le corps avec fond dégradé dans Android

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    tools:context=".MainActivity" 
    android:orientation="horizontal" 
    android:background="@drawable/gradient" 
    > 
<View 
    android:layout_width="13dp" 
    android:layout_height="fill_parent" 
    android:background="@drawable/shadow_left" /> 
</LinearLayout> 

enter image description here

Shadow_Left.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
     <gradient 
     android:startColor="#385469" 
     android:endColor="#316a84" 
     android:angle="180" 
     > 
    </gradient> 
    </shape> 

Pour la mise en page suivante, j'ai essayé le code suivant. enter image description here

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="70dp" 
     android:background="@android:color/black" 
     > 
    <View 
      android:layout_width="match_parent" 
      android:layout_height="5dp" 
      android:layout_alignParentBottom="true" 
      android:background="@android:color/holo_blue_light" /> 
    </RelativeLayout> 
    <View 
    android:layout_width="wrap_content" 
    android:layout_height="8dp" 
    android:background="@drawable/shadow_top"/> 
    <LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/gradient_right" 
    android:orientation="horizontal" 
    > 

shadow_top.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
      <gradient 
      android:startColor="#385469" 
      android:endColor="@android:color/transparent" 
      android:angle="270" 
      > 
     </gradient> 
    </shape> 

Mais au lieu de fin transparent, il me donne une fin blanche. La même sortie était là quand j'ai utilisé une image d'ombre png là-bas. Dans les deux cas transparent remplacé par une extrémité blanche. Comment atteindre la sortie en tant que deuxième image?

+0

peut vous envoyer les « mise en page suivante » xml –

Répondre

0

Parce que votre View est au-dessus du LinearLayout donc si votre View est transparent, vous verrez la LinearLayout
La couleur blanche dans l'image est la couleur de LinearLayout.

Pour voir cet effet, vous pouvez changer la couleur LinearLayout

+0

Merci, maintenant je l'ai changé le gradient de backround à LinearLayout principal. –