在我的應用我改變反彈時發光效果的顏色是這樣的:的Android棒棒糖滾動型邊緣效應顏色
int glowDrawableId = contexto.getResources().getIdentifier("overscroll_glow", "drawable", "android");
Drawable androidGlow = contexto.getResources().getDrawable(glowDrawableId);
assert androidGlow != null;
androidGlow.setColorFilter(getResources().getColor(R.color.MyColor), PorterDuff.Mode.SRC_ATOP);
但是,當我更新棒棒糖該代碼崩潰。我得到以下錯誤代碼:
FATAL EXCEPTION: main
Process: com.myproject.myapp, PID: 954
android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.Resources.getValue(Resources.java:1233)
at android.content.res.Resources.getDrawable(Resources.java:756)
at android.content.res.Resources.getDrawable(Resources.java:724)
似乎在棒棒糖中缺少overscroll_glow資源。 我如何在棒棒糖中實現這一點?
在此先感謝。
一般而言,您不應該嘗試引用這樣的框架專用資源。它們不保證在操作系統更新或甚至同一操作系統的不同OEM定製版本之間持續存在。 – alanv 2014-11-24 18:20:34