【发布时间】:2015-03-21 17:01:24
【问题描述】:
我注意到启用硬件加速后,我的应用程序中的 WebView 非常慢,因此我在清单应用程序级别禁用了它。
问题是,支持 CardView 的 Android 5.0 实现需要硬件加速来绘制阴影,我可以在 Lollipop 设备上使用 Pre 5.0 逻辑吗?
在 2.3、4.3、4.4 版本上测试的相同代码工作正常,CardView 阴影在 5.0 上消失了。 xml文件示例:
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/helper_view_card"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_marginBottom="1dp"
android:layout_marginLeft="1dp"
app:cardBackgroundColor="@color/white"
app:cardUseCompatPadding="true"
android:gravity="center_vertical|center_horizontal"
app:cardElevation="4dp">
【问题讨论】:
-
使用自定义库获得所有版本的阴影效果:D
-
是啊,好像只能这样了,可惜了,我真的很喜欢用CardView
-
我最终为 20 多个 API 版本启用了硬件加速
标签: java android drawing hardware-acceleration android-cardview