美文网首页
CardView在安卓5.0以下的坑

CardView在安卓5.0以下的坑

作者: 晓晓罗 | 来源:发表于2017-06-28 14:52 被阅读511次

    最近做项目用到了新控件CardView,结果发现安卓4.4的情况下出现这样的情况


    image.png

    很明显的坑爹,,,,

    后来查找资料发现,在CardView添加以下属性代码即可(app:cardPreventCornerOverlap="false"):

    <android.support.v7.widget.CardView 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="24px"
        android:layout_marginRight="24px"
        android:elevation="6px"
        app:cardCornerRadius="10px"
        app:cardPreventCornerOverlap="false">
    
    
    

    然而更坑爹的来了,背景的蓝色尖角居然把cardview的圆角给挡住了。。。。。

    没办法,只能把蓝色背景的样式加上圆角

    <shape xmlns:android="http://schemas.android.com/apk/res/android">
    
        <gradient
            android:angle="0"
            android:endColor="#32b4ff"
            android:startColor="#32ccff" />
    
        <corners
            android:bottomLeftRadius="10px"
            android:topLeftRadius="10px" />
    </shape>
    

    相关文章

      网友评论

          本文标题:CardView在安卓5.0以下的坑

          本文链接:https://www.haomeiwen.com/subject/fhyucxtx.html