简体   繁体   English

Android-自定义操作栏

[英]Android - Customize the Action Bar

I need to customize my Action Bar by changing color, substitute the default icons (settings and the "back" arrow) with custom images, and remove the Action Bar title with a custom font placed at the center of the Action Bar. 我需要通过更改颜色来自定义操作栏,用自定义图像替换默认图标(设置和“后退”箭头),然后使用位于操作栏中央的自定义字体删除操作栏标题。

How can I apply these changes? 如何应用这些更改?

I already tried to change the background color of the Action Bar but it doesn't work, can you tell me why please? 我已经尝试过更改操作栏的背景颜色,但是它不起作用,您能告诉我为什么吗?

<style name="AppBaseTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/aBbG</item>
</style>

<style name="aBbG" parent="@android:style/Widget.Holo.Light.ActionBar">
    <item name="android:background">#b10600</item>
</style>

Very thanks in advance! 提前非常感谢!

I suggest you this way : 我建议你这样:

I suggest a way to you below , you can do like that( it is just one way I think) 我在下面向您建议一种方法,您可以那样做(这只是我认为的一种方法)

  • Hide your actionbar. 隐藏动作栏。 like this : actionBar.hide(); 像这样: actionBar.hide();
  • then create linearlayout and put it in your main activty which calls your fragments 然后创建linearlayout并将其放在您的主要activty ,该活动会调用您的fragments
  • then you can customize your layout as you needs. 然后您可以根据需要自定义布局。

I do it as I said. 我照我说的做了。 You can see the screenshot below:(it is not actionbar it is linearlayout) 您可以看到以下屏幕截图:(它不是动作栏,而是linearlayout)

在此处输入图片说明

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

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