2016-04-30 10 views
1

Ich versuche, dies für Monate zu tun und schließlich kann ich nicht finden, trotzdem. Elevation ist nur für API 21+ und andere Möglichkeiten funktionieren manchmal und manchmal nicht. Ich arbeite an einem Musik-Player und ich brauche Schatten zwischen Musik-Controller und Musik-Cover. Wie füge ich Schatten hinzu? Erhebung nicht funktioniert hier wie SieFügen Schatten zwischen Layout

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

    <ImageView 
     android:id="@+id/now.playing.cover" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="#ffffff" 
     android:scaleType="centerInside"/> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/colorPrimaryDark" 
     android:gravity="center_horizontal" 
     android:orientation="vertical" 
     android:padding="8dp"> 

     <TextView 
      android:id="@+id/now.title" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:maxLines="1" 
      android:textColor="@color/colorSecondaryText" /> 

     <TextView 
      android:id="@+id/now.artist" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:maxLines="1" 
      android:textColor="@color/colorSecondaryText" /> 

     <TextView 
      android:id="@+id/now.album" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:maxLines="1" 
      android:textColor="@color/colorSecondaryText" /> 

     <android.support.v7.widget.AppCompatSeekBar 
      android:id="@+id/now.seek" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:orientation="horizontal" 
      android:paddingLeft="32dp" 
      android:layout_marginTop="8dp" 
      android:paddingRight="32dp"> 

      <ImageView 
       android:id="@+id/prev" 
       android:layout_width="36dp" 
       android:layout_height="36dp" 
       android:layout_marginRight="56dp" 
       android:padding="2dp" 
       android:src="@drawable/prev" /> 

      <ImageView 
       android:id="@+id/pp" 
       android:layout_width="36dp" 
       android:layout_height="36dp" 
       android:layout_marginRight="56dp" 
       android:padding="2dp" 
       android:src="@drawable/play" /> 

      <ImageView 
       android:id="@+id/next" 
       android:layout_width="36dp" 
       android:layout_height="36dp" 
       android:padding="2dp" 
       android:src="@drawable/next" /> 
     </LinearLayout> 
    </LinearLayout> 
</LinearLayout> 

enter image description here

Antwort

2

Sie eine Ansicht hinzufügen können, zwischen denen sieht aus wie Schatten sehen kann .. Im Folgenden ist ein Beispiel für gleiche, die ich verwendet habe, und es ist fast Werke auf allen apis .. Vielleicht ist es Ihnen ..

Schatten Ansicht helfen:

<View 
     android:id="@+id/toolbar_shadow" 
     android:layout_width="match_parent" 
     android:layout_height="15dp" 
     android:layout_below="@+id/toolbar" 
     android:background="@drawable/toolbar_shadow" /> 

Und die ziehbar Datei:

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle" > 

    <gradient 
     android:angle="90" 
     android:endColor="#88444444" 
     android:startColor="#00000000" /> 
</shape> 

It will look like this

+0

Dank, dass ein guter Weg, –

Verwandte Themen