简体   繁体   English

操作栏自定义视图

[英]Action bar custom view

I want to declare a custom view, BUT I also want the home logo with up icon to appear on the left with its default functionality. 我想声明一个自定义视图,但我也希望带有向上图标的主页徽标显示在左侧,并带有默认功能。 How can I achieve to use both? 如何同时使用两者?

Best way is to use XML styles: 最好的方法是使用XML样式:

<style name="Theme.Main" parent="android:Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/Widget.ActionBar</item>
</style>

<style name="Widget.ActionBar" parent="android:Widget.Holo.Light.ActionBar">
    <item name="android:displayOptions">showHome|useLogo|showCustom</item>
    <item name="android:customNavigationLayout">@layout/custom</item>
</style>

Then simply set this theme as either the application theme or activity them in AndroidManifest.xml 然后只需将此主题设置为AndroidManifest.xml的应用程序主题或活动

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM