How to disable the shadow around card view in android

后端 未结 12 1774
陌清茗
陌清茗 2021-02-01 11:34

Hello I am am working on demo application in which i am using the card view of support library. By default it is adding shadow around it. I want to remove this shadow & shou

相关标签:
12条回答
  • 2021-02-01 12:15

    You have to use the following attributes

    <android.support.v7.widget.CardView
        android:id="@+id/card_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:cardElevation="0dp"
        app:cardCornerRadius="0.5dp"
        app:cardPreventCornerOverlap="false"
        >
       </android.support.v7.widget.CardView>
    
    0 讨论(0)
  • 2021-02-01 12:18

    Try to put the elevation in Xml.

    app:cardElevation="0dp"
    

    OR

    cardView.setCardElevation(0);
    

    And check you are using the latest CardView library.

    0 讨论(0)
  • 2021-02-01 12:19

    use app:cardElevation="0dp", don't use app:elevation="0dp"

    0 讨论(0)
  • 2021-02-01 12:19
     <android.support.v7.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:cardElevation="0dp"
            app:cardCornerRadius="2dp">
    ....`
     </android.support.v7.widget.CardView>
    
    0 讨论(0)
  • 2021-02-01 12:20

    Just put this line inside your CardView:

    app:cardElevation="0dp"
    

    Hope it will help you.

    0 讨论(0)
  • 2021-02-01 12:25

    use this attribute in XML

    card_view:cardElevation="0dp"
    

    and remember add xmlns:card_view="http://schemas.android.com/tools" in your root layout.

    OR you can call cardView.setCardElevation(0) to disable shadow programmatically.

    cardView.setElevation() method and CardView attribute android:elevation will throw java.lang.NoSuchMethodError in platform before Android 5.0

    0 讨论(0)
提交回复
热议问题