android - Get the Theme value applied for an activity programmatically -


I want to know which themes are implemented for any activity in an app.

Normally we are setting the theme by using

  settheme (android.r.style.Theme_Light);   

Here we are specifying style, such that we may be able to achieve a specific type of style for an activity in the program.

Thanks

called getThemeResId in the reference class There is a good method, although it is private so you need to use the reflection. / P>

Here's an example:

  @ override protected form zero (bundle savedinstenstate) {super.New (savedinstenstate); SetContentView (R.layout.activity_my); Logs. E ("tag", "def theme:" + R. style. Aaptim); Logs. E ("tag", "light theme:" + android.r.style.me_Light); Logs. E ("tag", "current theme id:" + receivedTheme ()); SetTheme (android.R.style.Theme_Light); Logs. E ("tag", "current theme id:" + receivedTheme ()); } Int getThemeId () {try {class & lt ;? & Gt; Wrapper = Context.class; Method method = wrapper.getMethod ("getThemeResId"); Method.setAccessible (true); Return (integer) method.invoke (this); } Hold (exception e) {e.printStackTrace (); } Return 0; }    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -