I am trying to apply custom theme to ActionBar
in PreferenceFragment
. Following is the scenerio:
My class extends PreferenceFragment
in which I am adding preferences from resouces as:
addPreferenceFromResource (R.xml.myPrefs);
Also, I have written:
ActionBar a = getActivity ().getActionBar ();
bar.setNavigationMode (ActionBar.NAVIGATION_MODE_TABS);
Now I want to apply my own theme that I defined in styles.xml
to this action bar. Currently, the height of action bar is smaller that the tab view due to which the view is getting cropped.
I tried searching but couldn't find a solution to my problem.
- "Set theme for a Fragment"
- https://groups.google.com/forum/#!topic/android-developers/GX_gOAN2nmM
From 1. and 2. links above, I learnt that:
final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(),R.style.yourCustomTheme);
// clone the inflater using the ContextThemeWrapper
LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper);
// inflate the layout using the cloned inflater, not default inflater
return localInflater.inflate(R.layout.yourLayout, container, false);
But this also didn't work.
Any help is highly appreciated.