Home » Android » How to access android default images ( for example image for seekbar's thumb when is pressed ) from java code?

How to access android default images ( for example image for seekbar's thumb when is pressed ) from java code?

Posted by: admin June 15, 2020 Leave a comment

Questions:

How to access android default images ( for example image for seekbar’s thumb when is pressed ) from java code ? I am changing thumb but and I copy from platforms/android-12/data/res/drawable-hdpi into my drawable-hdpi folder in project, but it is platform dependent ( color of item, size and so on). Can someone show me how to access this android default item from java code ?

How to&Answers:

Android contains a number of standard resources, such as styles, themes, and layouts. To access these resource, qualify your resource reference with the android package name. For example,

 ImageView img = (ImageView)findViewById(R.id.imgView1);
 img.setImageResource(android.R.drawable.ic_media_play);

Note: but you can only access the resources which are available in android.R packages..’

Look at here android.R

Answer:

In general, in order to access the Android resources using code, you should use android.R.[whatever you want i.e. layout, drawable, etc].

Hope this helps,
In case you need any other specific help, please shoot it!

Answer:

At the end of the article Accessing Resources you can found an answer.