Create custom titlebar in Android(在 Android 中创建自定义标题栏)
问题描述
我为我的应用程序创建了一个自定义标题栏,但我在实现它时遇到了一些问题.我想更改文本和标题栏的颜色和外观
I created a custom title bar for my application but I am having some problems implementing it. I want to change the color and the appearance for the text and title bar
styles.xml 的布局如下:
The layout of the styles.xml is as below:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyTheme">
<item name="android:tabWidgetStyle">@style/LightTabWidget</item>
</style>
<style name="MyWindowTitleBackground" parent="@android:style/WindowTitleBackground">
<item name="android:background">@android:drawable/title_bar</item>
</style>
<style name="MyWindowTitle" parent="@android:style/WindowTitle">
<item name="android:singleLine">true</item>
<item name="android:windowTitleSize">40dip</item>
<item name="android:textAppearance">@style/MyTextAppearance</item>
<item name="android:shadowColor">#BB000000</item>
<item name="android:shadowRadius">2.75</item>
</style>
<style name="MyTextAppearance" parent="@android:style/TextAppearance.WindowTitle">
<item name="android:textColor">#3A6629</item>
<item name="android:textSize">14sp</item>
<item name="android:textStyle">bold</item>
</style>
<style name="LightTabWidget" parent="@android:style/Widget.TabWidget">
<item name="android:textSize">20px</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">#FF5721</item>
</style>
</resources>
我在清单文件中添加了该主题,如下所示:
And I have added that theme in the manifest file as follows:
<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@android:style/Theme.Light">
<activity android:name="LAFoodBankAboutUs" android:label="@string/app_name" android:theme="@style/MyTheme">
我必须做什么才能显示自定义标题栏?
What do I have to do to show the custom title bar?
推荐答案
到现在(几年后),工具栏 可用.它具有很多 自定义 可能性,也可以通过支持库
By now (after some years), the Toolbar is available. It features a lot of customization possibilities and is also available via the Support Library
这篇关于在 Android 中创建自定义标题栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Android 中创建自定义标题栏


- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01