【问题标题】:Android CardView shadow gets cut offAndroid CardView 阴影被切断
【发布时间】:2021-03-26 00:26:14
【问题描述】:

阴影似乎切断了我的一些 CardView 用法。 知道为什么吗?看起来删除父级上的填充可以解决问题,但我确实想要填充。而且我不想在内卡上使用边距,因为还有其他视图对齐,我更喜欢在父级上设置填充以应用于所有子级

有什么解决办法吗?

布局

<?xml version="1.0" encoding="utf-8"?>

<androidx.cardview.widget.CardView 
xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="@dimen/standard_spacing"
    android:layout_marginLeft="@dimen/standard_spacing"
    android:layout_marginRight="@dimen/standard_spacing"
    android:layout_marginBottom="@dimen/smaller_spacing"
    app:cardCornerRadius="@dimen/standard_card_corner_radius"
    app:cardElevation="10dp">

    <androidx.appcompat.widget.LinearLayoutCompat
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:padding="@dimen/standard_spacing">

        <androidx.cardview.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:cardBackgroundColor="@color/light_gray_background"
            android:minHeight="40dp"
            app:cardElevation="5dp"
            app:cardCornerRadius="@dimen/standard_card_corner_radius" >

        </androidx.cardview.widget.CardView>

    </androidx.appcompat.widget.LinearLayoutCompat>

</androidx.cardview.widget.CardView>

【问题讨论】:

    标签: android android-cardview shadow


    【解决方案1】:

    添加

    android:clipToPadding="false"
    

    到线性布局

    【讨论】:

      猜你喜欢
      • 2013-07-26
      • 1970-01-01
      • 1970-01-01
      • 2015-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-06
      相关资源
      最近更新 更多