我在这样的 RecyclerView 中使用 CardView:
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="4dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:foreground="?android:selectableItemBackground">
根据android API docs,填充应该是
maxCardElevation * 1.5 + (1 - cos45) * cornerRadius
当我 System.out.print 时,maxElevation 为 4.0,导致填充 ~7.17。但是,当我打开 LayoutBounds 时,很容易看到填充实际上甚至不是 2 dp。
我正在尝试修复列表中的卡片间距,但在不知道实际填充的情况下这是不可能的。
有人对此事有任何见解吗?
编辑:我在带有 CyanogenMod11 M11 的 Nexus 4 上运行它