2016-04-14 227 views
0

我試圖從Cardview中刪除陰影。
我用支持Android V7 Cardview在Android v4.4.2
Android 4.4從CardView中刪除陰影

我看佈局:

<android.support.v7.widget.CardView 
    android:id="@+id/cardContainer" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@null" 
    card_view:cardBackgroundColor="@color/transparent" 
    card_view:cardCornerRadius="0dp" 
    card_view:cardElevation="0dp" 
    card_view:cardPreventCornerOverlap="false" 
    card_view:contentPadding="0dp"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <include layout="@layout/include_profile_header" /> 

     <include layout="@layout/include_profile_footer" /> 

    </RelativeLayout> 

</android.support.v7.widget.CardView> 

正如你可以看到我使用:

card_view:cardElevation="0dp" 

到目前爲止已經試過:

android:background="@null" 

但是你仍然可以在圖像中看到我附上了顯示的頂部陰影。

CardView Shadow

+0

嘗試刪除cardBackgroundColor @ motis10 –

+0

安卓cardBackgroundColor不存在,card_view:cardBackgroundColor既不 – motis10

+0

card_view:cardBackgroundColor =「@色/透明「刪除此 –

回答

0

不能在4.4從cardview去除陰影。低於5.0海拔什麼都沒有所以所有的cardview是4.4是一個影子

要與陰影創建一個卡,使用card_view圖像:cardElevation 屬性。 CardView使用Android 5.0(API級別21)及更高級別上的真實仰角和動態陰影,並回退到早期版本上的編程陰影實現。有關更多信息,請參閱 維護兼容性。

http://developer.android.com/training/material/lists-cards.html#CardView

+0

因此,這意味着我需要更改佈局CardView到另一個視圖組,並手動添加陰影只是如果我需要? – motis10

+0

這將是正確 – tyczj

+0

但是,它的聲音奇怪。你說5.0之前的cardview不使用cardElevation,maxcardElevation,cardPreventCornerOverlap, – motis10

0

我只是用相對佈局,而不是固定的這個問題。只需將CardView值更改爲一個相對佈局,你將基本上得到相同的結果,但沒有陰影