Trong ứng dụng của tôi thay đổi màu sắc hiệu ứng ánh sáng thanh cuộn như thế này:Android Lollipop scrollview hiệu lực cạnh màu
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);
Nhưng khi tôi cập nhật để lollipop mã này bị treo. Tôi nhận được mã lỗi sau:
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)
Dường như tài nguyên bị ghi đè quá thiếu trong kẹo. Làm thế nào tôi có thể đạt được điều này trong kẹo?
Xin cảm ơn trước.
Nói chung, bạn không bao giờ nên cố gắng tham khảo các tài nguyên khung công tác như vậy. Chúng không được đảm bảo tồn tại trên các bản cập nhật hệ điều hành hoặc thậm chí giữa các phiên bản OEM tùy chỉnh khác nhau của cùng một hệ điều hành. – alanv