我正在使用PropertyValuesHolder爲我的Android應用程序中的一些視圖設置動畫。動畫在我的設備上運行良好,直到我做一個沒有任何動畫的發佈版本。 (我認爲問題與混淆有關,因爲屬性名稱被稱爲字符串名稱,例如「Panel1W」)如何使用Android PropertyValuesHolder與proguard
沒有異常拋出。只是沒有動畫。我在http://proguard.sourceforge.net/index.html#manual/troubleshooting.html上找到的最接近的東西是NoSuchMethodException,我們需要在proguard.cfg中使用-keep命令。我嘗試了以下在我的proguard.cfg但沒有成功
-keep public class com.mycompany.myapp.HomeActivity { java.lang.Integer getPanel1W(); }
-keep public class com.mycompany.myapp.HomeActivity { void setPanel1W(java.lang.Integer); }
-keep public class com.mycompany.myapp.HomeActivity { java.lang.Integer getPanel2W(); }
-keep public class com.mycompany.myapp.HomeActivity { void setPanel2W(java.lang.Integer); }
-keep public class com.mycompany.myapp.HomeActivity { java.lang.Integer getPanel3W(); }
-keep public class com.mycompany.myapp.HomeActivity { void setPanel3W(java.lang.Integer); }
我是否缺少任何東西?以下是代碼。謝謝。
PropertyValuesHolder[] arrayOfPropertyValuesHolder = new PropertyValuesHolder[3];
arrayOfPropertyValuesHolder[0] = PropertyValuesHolder.ofInt("Panel1W", mPanel1.getWidth(), 0);
arrayOfPropertyValuesHolder[1] = PropertyValuesHolder.ofInt("Panel2W", 360, 1280);
arrayOfPropertyValuesHolder[2] = PropertyValuesHolder.ofInt("Panel3W", 0, (int)(screenWidth * 0.65));
ObjectAnimator localObjectAnimator = ObjectAnimator.ofPropertyValuesHolder(this,
arrayOfPropertyValuesHolder).setDuration(time);
localObjectAnimator.setInterpolator(sCollapseInterpolator);
localObjectAnimator.start();
我也有getter和setter方法。
public int getPanel1W() {
return ((ViewGroup.MarginLayoutParams) mPanel1.getLayoutParams()).width;
}
public void setPanel1W(int paramInt) {
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) mPanel1.getLayoutParams();
lp.width = paramInt;
mPanel1.setLayoutParams(lp);
}
public int getPanel2W() {
return ((ViewGroup.MarginLayoutParams) mPanel2.getLayoutParams()).width;
}
public void setPanel2W(int paramInt) {
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) mPanel2.getLayoutParams();
lp.width = paramInt;
mPanel2.setLayoutParams(lp);
}
public int getPanel3W() {
return ((ViewGroup.MarginLayoutParams) mPanel3.getLayoutParams()).width;
}
public void setPanel3W(int paramInt) {
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) mPanel3.getLayoutParams();
lp.width = paramInt;
mPanel3.setLayoutParams(lp);
}
謝謝,我試着在類中定義字符串,並試圖保持整個類與 - 公共類但即使這沒有工作,所以也許我在錯誤的軌道。感謝您的意見 –
Dittimon
2012-07-27 06:02:39