问题描述
应用Proguard后,我的CardView阴影在Lollipop设备上消失了.我没有定义任何保护该库的规则,因为我根本没有读过它.
My CardView's shadows have disappeared on Lollipop devices after applying Proguard. I haven't defined any rule to protect this library, because I haven't read it was necessary at all.
我附上了两个屏幕截图,首先是不运行proguard,然后是运行后的secon.
I attach you a couple of screenshots, first without running proguard, and secon after running it.
这是我的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>
活动仅将xml设置为内容,并且仅执行其他操作.如您所见,我正在使用cardUseCompatPadding
的两种可能性,但它不能解决问题,因为它在.
Activity only sets the xml as content and does nothing more.As you can see, I'm using the two possibilities of cardUseCompatPadding
, but it doesn't solve the issue as it's defined in this thread.
有人知道为什么proguard破坏了我的阴影吗?
Does anybody know why proguard is breaking my shadows?
推荐答案
在库包中进行了一些潜水之后,我编写了一条规则来保护android.support.**上的所有内容,现在我终于只保护了android.support. .v7.widget.RoundRectDrawable.
After some diving in the library packages, I wrote a rule that protected everything at android.support.** and now I'm finally protecting just android.support.v7.widget.RoundRectDrawable.
因此,如果您对此有疑问,只需在您的proguard配置中添加下一条规则即可:
So if you are having troubles with this, just add the next rule at your proguard config:
-keep class android.support.v7.widget.RoundRectDrawable { *; }
这篇关于使用Proguard混淆后,CardView阴影未出现在棒棒糖中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!