棒棒糖安装前设备上带有CardView的空白区域 [英] White Space with CardView on pre-lollipop devices

查看:81
本文介绍了棒棒糖安装前设备上带有CardView的空白区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在应用程序的某些视图上添加圆角和阴影,并利用卡视图库来实现这一点.在棒棒糖设备上看起来不错,但与任何棒棒糖之前的产品都存在兼容性问题.

首先,我要看下面问题的答案,发现没有一个对我有用.

  • 在4.4.2上完全相同的代码显示为:

    使用'cardPreventOverlap = false':

    更新:很遗憾,我们无法解决此问题;鉴于该应用程序的安装基数只有pre5.0以下,因此我们认为它并不重要.我们最后选择了第三个选项'cardPreventOverlap = false'.

    解决方案

    不支持内容裁剪,因为在较旧的设备上费用很高.如果愿意,可以使用

    I am attempting to add rounding and shadows to some views on an app and am utilizing the card view library to achieve that. It is looking good on lollipop devices but am running into compatibility issues with anything pre-lollipop.

    I will preface this by saying that I have looked at the answers in the questions below have found that none of them are working for me.

    The most popular answer was to add the attribute 'cardPreventOverlap=false' but this removes the rounded corners. I have tried variations of this flag and 'cardUseCompatPadding="true"' but none of them seem to do the trick. Has anyone else run into the same problem?

    My code:

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        card_view:cardCornerRadius="4dp">
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/selector"
            android:gravity="center"
            android:orientation="horizontal" >
    
            <ImageView
                android:layout_width="44dp"
                android:layout_height="match_parent"
                android:layout_marginRight="4dp"
                android:background="@color/mid_yellow"
                android:padding="0dp"
                android:src="@drawable/ic_add_white_24dp" />
    
            <TextView
                style="@style/Text.Primary.White"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="4dp"
                android:text="Button" />
        </LinearLayout>
    

    This is how it currently looks on Android 5.0:

    The exact same code on 4.4.2 displays as:

    With 'cardPreventOverlap=false':

    Update Unfortunately we were not able to solve the issue; given that the app only had small install base pre5.0 we decided it was not important. We ended up going with the third option 'cardPreventOverlap=false'.

    解决方案

    Content clipping is not supported, because is quite expensive on older devices. If you wish, you can use Carbon. It has its own CardView implementation, which correctly clip content to rounded corners. Carbon also adds content clipping and elevation to all other layouts so for your purpose you can use a LinearLayout with rounded corners and shadow. See the image:

    这篇关于棒棒糖安装前设备上带有CardView的空白区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆