微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android – 如何使用导航抽屉添加自定义操作栏?

我尝试使用自定义操作栏作为:
bar.setdisplayOptions(ActionBar.disPLAY_SHOW_CUSTOM);
        bar.setCustomView(R.layout.xyz);

但导航抽屉变得不可见.

解决方法

我有同样的问题,但我找到了解决问题的方法.你需要设置:
getActionBar().setCustomView(R.layout.xyz);
getActionBar().setdisplayOptions(ActionBar.disPLAY_SHOW_CUSTOM | ActionBar.disPLAY_SHOW_HOME | ActionBar.disPLAY_HOME_AS_UP);

然后,它将显示导航抽屉图标.

如果您不希望图标可见,您可以放置​​透明图像(只需使透明图像transparent.png并放入可绘制文件夹)而不是应用程序图标.您可以通过为Action Bar(styles.xml)定义新样式来实现此目的:

<style name="Theme.MyAppTheme" parent="android:style/Theme.Holo.Light">
     <item name="android:actionBarStyle">@style/Theme.MyAppTheme.ActionBar</item>
</style>
<style name="Theme.MyAppTheme.ActionBar" parent="android:style/Widget.Holo.Light.ActionBar">
    <item name="android:icon">@drawable/transparent</item>
</style>

原文地址:https://www.jb51.cc/android/313592.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐