Angelo.Hannes
Angelo.Hannes

Reputation: 1729

Using Android internal drawables

I'm trying to write a tristate switch. But I'm failing to access the default com.android.internal.R.styleable.Switch_track drawable to use as background.

How to get that drawable?

Is there another approach for getting the default background?

Upvotes: 5

Views: 2564

Answers (2)

yonojoy
yonojoy

Reputation: 5566

Just for reference: While it is not advised to access internal resources and you should be aware, that they can change or could be removed by a vendor or with an OS update, it is possible to access them at runtime:

int id = Resources.getSystem().getIdentifier("Switch_track", "styleable", "android");

Upvotes: 5

Tomik
Tomik

Reputation: 23977

You should not access private resources, you can't be sure that the resource will be available on all devices. And even if it is available, you can't be sure it will be the same.

If you want to use a private resource, you have to copy it into your project resources from SDK or Android sources.

Upvotes: 5

Related Questions