我在使用新的 CardView 时遇到了一些问题
这就是我目前的情况:我想使用 CardView 为所有设备提供一个浮动操作按钮(也是 Pre-Lollipop)
我的活动布局看起来像这样
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cardview="http://schemas.android.com/apk/res-auto"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#cdcdcd"
android:focusable="false">
<include layout="@layout/toolbar"/>
<android.support.v7.widget.CardView
android:layout_width="58dp"
android:layout_height="58dp"
cardview:cardPreventCornerOverlap="true"
android:layout_gravity="bottom|right"
android:layout_marginBottom="16dp"
android:layout_marginRight="18dp"
cardview:cardCornerRadius="29dp"
cardview:cardBackgroundColor="?attr/colorPrimary">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center"
android:layout_margin="12dp"
android:src="@android:drawable/ic_menu_edit"/>
</android.support.v7.widget.CardView>
在 Nexus 5 (4.4.4) 上运行应用程序,屏幕如下所示:
现在我想通过在 xml 中设置它来设置 cardElevation
cardview:cardElevation="8dp"
启动应用程序后,按钮如下所示(不再是圆圈):
似乎设置卡片高度也会影响视图的尺寸......如果您现在仔细查看图片#1,您会看到,这个按钮也不是一个完美的圆形。
有没有办法解决这个问题?我也尝试设置这个
cardview:cardPreventCornerOverlap="false"
但这也没有影响
多谢你们 :)