How to use default graphic elements for Android

What is the best approach when using default graphics adapters for Android? Should I use android.R.drawable or do I need to copy drawings in my project and use R.drawable ?

Is there a risk that in a newer version of Android some of the drawings are deleted or changed by default? Or, say, in some negative way, the look of my application? Also, which of the drawings in the Android source code is considered β€œstable” and should you rely on it?

I would prefer not to copy the drawings, because I think that the appearance of the application should match the version of Android used. So, for example, for version 1.6, it should use the default Android bitmaps for version 1.6.

+55
android drawable
Jul 08 '10 at 8:01
source share
6 answers

If you read any discussions in the Android development team, you will see that they hinder the use of something that is not in the public SDK, because the rest is subject to significant changes.

+20
Jul 08 2018-10-10T00:
source share

Java usage example: myMenuItem.setIcon(android.R.drawable.ic_menu_save);

Resource usage example: android:icon="@android:drawable/ic_menu_save"

+97
May 2 '13 at 18:55
source share

As far as I remember, the documentation recommends not using the menu icons from android.R.drawable directly and recommends copying them to a folder with your capabilities. The main reason is that these badges and names are subject to change and may not be available in future releases.

Warning. Since these resources may vary between versions of the platform, you should not refer to these icons using the Android platform resource identifiers (for example, menu icons under android.R.drawable). If you want to use any icons or other internal available resources, you must save a local copy of these icons or drawings in your application resources, and then specify the local copy from your application code. Thus, you can control the appearance of your icons, even if the system copy changes.

from: http://developer.android.com/guide/practices/ui_guidelines/icon_design_menu.html

+34
Jul 08 '10 at 11:52
source share

Better copy and move them to your own resources. Some resources may not be available in previous versions of Android. Here is a link with all versions available for each version of Android thanks to @fiXedd

+21
Jul 08 '10 at 9:51
source share

To use the default resource for android, you don’t need to copy anything .. you can just import it first with.

 import android.R; 

but I will make your own resources have an error if you want to use it. The error will look something like this:

R. cannot be allowed

So, I prefer not import android.R , but import *my.own.package*.R;

then when I can usually use my own resource with R.drawable.*something* without errors, and put android.R.*something_default* to use the default android resources.

+7
Jul 29 2018-11-11T00:
source share

It is better to use android.R.drawable because it is publicly available and documented.

+3
Jul 08 '10 at 8:11
source share



All Articles