【发布时间】:2013-09-16 09:49:26
【问题描述】:
我正在尝试将自定义主题应用于PreferenceFragment 中的ActionBar。以下是场景:
我的课程扩展了PreferenceFragment,我在其中添加了来自资源的首选项:
addPreferenceFromResource (R.xml.myPrefs);
另外,我写过:
ActionBar a = getActivity ().getActionBar ();
bar.setNavigationMode (ActionBar.NAVIGATION_MODE_TABS);
现在我想将我在styles.xml 中定义的主题应用到此操作栏。目前,action bar 的高度小于导致视图被裁剪的选项卡视图。
我尝试搜索,但找不到解决问题的方法。
从上面的 1. 和 2. 链接中,我了解到:
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);
但这也没有用。
非常感谢任何帮助。
【问题讨论】:
标签: android android-fragments android-actionbar android-preferences