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 中创建自定义标题栏


基础教程推荐
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01