2017-01-12 3 views
1

У меня есть выровненный снимок CardView до экрана, который не соответствует высоте. Я хочу добавить больше тени в начало CardView. Я попытался сКак добавить тень на CardView, выровненную до нижней части родителя

android:shadowColor="#000" 
    android:shadowDx="0" 
    android:shadowDy="30" 
    android:shadowRadius="50" 

Но не вижу никаких изменений это мой код:

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:clipToPadding="false" 
     android:clipChildren="false" 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

    <!--rest of the code--> 

    <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_alignParentBottom="true" 
      android:shadowColor="#000" 
      android:shadowDx="0" 
      android:shadowDy="30" 
      android:shadowRadius="50" 
      android:layout_height="wrap_content"> 
     <android.support.v7.widget.CardView  
xmlns:app="http://schemas.android.com/apk/res-auto" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:elevation="8dp"       
      android:divider="@android:color/transparent" 
      android:dividerHeight="0.0px" 
      android:clipToPadding="false" 
      android:clipChildren="false" 
      app:cardElevation="10dp" 
      app:cardPreventCornerOverlap="false"> 

      <!--rest of the code--> 
    </android.support.v7.widget.CardView> 
    </LinearLayout> 

    </RelativeLayout> 

ответ

6

маржинального Ну не помогает, поэтому я ставлю на заполнение основной емкости и удалить все те теневые свойства, так как android:elevation="" является то, что делает работу.

Вот некоторые ясно код, который работает на этой потребности:

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:card_view="http://schemas.android.com/apk/res-auto" 
     android:clipToPadding="false" 
     android:clipChildren="false" 
     android:orientation="vertical" 
     android:padding="20dp" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

    <!--rest of the code--> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_alignParentBottom="true" 
     android:clipToPadding="false" 
     android:clipChildren="false" 
     android:layout_height="wrap_content"> 
    <android.support.v7.widget.CardView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:elevation="8dp" 
     android:divider="@android:color/transparent" 
     android:dividerHeight="0.0px" 
     android:clipToPadding="false" 
     android:clipChildren="false" 
     card_view:cardElevation="10dp" 
     card_view:cardPreventCornerOverlap="false"> 

     <TextView 
      android:layout_width="match_parent" 
      android:padding="20dp" 
      android:layout_height="wrap_content" 
      android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed 
      do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim 
      veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo 
      consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse 
      cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, 
      sunt in culpa qui officia deserunt mollit anim id est laborum" 
     /> 
    </android.support.v7.widget.CardView> 
    </LinearLayout> 

</RelativeLayout> 

И образ того, как это выглядит: enter image description here

3

Добавление полей вокруг представления, которые должны иметь тень может помочь.

+0

Как вы можете сделать это с кодом? – Merian

3

Добавляя маржу на карте Вид

<LinearLayout 
     android:layout_width="match_parent" 
     android:layout_alignParentBottom="true" 
     android:shadowColor="#000" 
     android:shadowDx="0" 
     android:shadowDy="30" 
     android:shadowRadius="50" 
     android:layout_height="wrap_content"> 

     <android.support.v7.widget.CardView 
      xmlns:app="http://schemas.android.com/apk/res-auto" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:elevation="8dp" 
      android:divider="@android:color/transparent" 
      android:dividerHeight="0.0px" 
      android:clipToPadding="false" 
      android:clipChildren="false" 
      app:cardElevation="10dp" 
      android:layout_margin="4dp" 
      app:cardPreventCornerOverlap="false"> 

      <!--rest of the code--> 
     </android.support.v7.widget.CardView> 
    </LinearLayout> 
Смежные вопросы