简体   繁体   English

从自定义应用程序主题设置android窗口标题栏图标

[英]Set android window title bar icon from custom application theme

Is it possible to set the window title bar title and icon from my own custom theme? 是否可以通过我自己的自定义主题设置窗口标题栏标题和图标? when i create a new Android project in eclipse and have it use AppTheme as shown here 当我在eclipse中创建一个新的Android项目并使用AppTheme时,如下所示

<style name="AppTheme" parent="android:Theme.Light" />

the window title bar title and icon appear as i want them. 窗口标题栏标题和图标如我所愿出现。

When i select my own theme in the mainfest file only the title shows in the window title bar and not the icon. 当我在mainfest文件中选择自己的主题时,仅标题显示在窗口标题栏中,而不显示图标。

My theme is as follows 我的主题如下

style name="GenericWallpaper" parent="android:Theme.Light"
item name="android:windowBackground">@drawable/blackbackground
item name="android:layout_width">fill_parent
item name="android:layout_height">fill_parent

I would rather use my xml style file to specify the icon and title are required than having to set it programatically in the window title bar in every activity. 我宁愿使用我的xml样式文件来指定所需的图标和标题,而不是必须在每个活动的窗口标题栏中以编程方式进行设置。

I am using android:minSdkVersion="8" , android:targetSdkVersion="15" 我正在使用android:minSdkVersion="8"android:targetSdkVersion="15"

You can use the Action Bar Style Generator . 您可以使用操作栏样式生成器 It is a free and open source tool made by Jeff Gilfelt. 它是Jeff Gilfelt制作的免费开源工具。

You can also have a look on a more complete blog post about Styling the ActionBar : Part 1 and Part 2 您还可以查看有关样式化ActionBar的更完整的博客文章: 第1 部分第2部分

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

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