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?
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");
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With