[英]Setting custom action bar view in theme
Is there a way to define a custom action bar view in the theme instead of setting it in every activity? 有没有一种方法可以在主题中定义自定义操作栏视图,而不是在每个活动中都进行设置? Currently I have this code in onCreate for every activity I have:
目前,对于每个活动,我在onCreate中都有此代码:
View actionBar = getLayoutInflater().inflate(R.layout.action_bar_title, null);
getActionBar().setCustomView(actionBar);
The custom view can be defined in the style of the action bar: 可以使用操作栏的样式定义自定义视图:
<style name="MyActionBarStyle" parent="@android:style/Widget.Holo.ActionBar">
<item name="android:displayOptions">showCustom</item>
<item name="android:customNavigationLayout">@layout/action_bar_title</item>
</style>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.