Posts

Showing posts with the label Android Resources

Android GetResources().getDrawable() Deprecated API 22

Answer : You have some options to handle this deprecation the right (and future proof ) way, depending on which kind of drawable you are loading: A) drawables with theme attributes ContextCompat.getDrawable(getActivity(), R.drawable.name); You'll obtain a styled Drawable as your Activity theme instructs. This is probably what you need. B) drawables without theme attributes ResourcesCompat.getDrawable(getResources(), R.drawable.name, null); You'll get your unstyled drawable the old way. Please note: ResourcesCompat.getDrawable() is not deprecated! EXTRA) drawables with theme attributes from another theme ResourcesCompat.getDrawable(getResources(), R.drawable.name, anotherTheme); Edit: see my blog post on the subject for a more complete explanation You should use the following code from the support library instead: ContextCompat.getDrawable(context, R.drawable.***) Using this method is equivalent to calling: if (Build.VERSION.SDK_INT ...

Android XXHDPI Resources

Answer : According to the post linked in the G+ resource: The gorgeous screen on the Nexus 10 falls into the XHDPI density bucket. On tablets, Launcher uses icons from one density bucket up [0] to render them slightly larger. To ensure that your launcher icon (arguably your apps most important asset) is crisp you need to add a 144*144px icon in the drawable-xxhdpi or drawable-480dpi folder. So it looks like the xxhdpi is set for 480dpi. According to that, tablets use the assets from one dpi bucket higher than the one they're in for the launcher. The Nexus 10 being in bucket xhdpi will pull the launcher icon from the xxhdpi. Source Also, was not aware that tablets take resources from the asset bucket above their level. Noted. The DPI of the screen of the Nexus 10 is ±300, which is in the unofficial xhdpi range of 280‑400. Usually, devices use resources designed for their density. But there are exceptions, and exceptions might be added in the future. T...