应用 Proguard 后,我的 CardView 的阴影在 Lollipop 设备上消失了。我没有定义任何规则来保护这个库,因为我还没有读到它是必要的。
我附上了几个屏幕截图,第一个是未运行 proguard 的,第二个是运行后的。
这是我的xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<android.support.v7.widget.CardView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_margin="4dp"
app:contentPadding="10dp"
app:cardUseCompatPadding="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text 1"/>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_margin="4dp"
app:contentPadding="10dp"
app:cardUseCompatPadding="false">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text 2"/>
</android.support.v7.widget.CardView>
</LinearLayout>
Activity 仅将 xml 设置为内容,仅此而已。
如您所见,我正在使用 cardUseCompatPadding
的两种可能性,但它并没有解决 this thread 中定义的问题。 .
有人知道为什么 proguard 会破坏我的影子吗?
最佳答案
在深入了解库包之后,我编写了一条规则来保护 android.support.** 中的所有内容,现在我终于只保护 android.support.v7.widget.RoundRectDrawable。
因此,如果您遇到问题,只需在混淆器配置中添加下一条规则:
-keep class android.support.v7.widget.RoundRectDrawable { *; }
关于android - 使用混淆器混淆后,CardView 阴影未出现在 Lollipop 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29679177/