如何改变标题栏的颜色在android的活动? [英] How to change title bar color in android activity?

查看:123
本文介绍了如何改变标题栏的颜色在android的活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  设置标题背景颜色

如何更改标题栏的颜色在一个Android应用程序?

How can I change the titlebar color in an Android app?

我想:

this.setTitleColor(Color.BLUE); 

但它改变了书面文字的颜色就可以了没有标题栏的颜色。

but it changes color of written text on it not title bar color.

推荐答案

getWindow()上下文的方法返回当前视图背景下,得到一个活动的标题栏,android.id.id.title

getWindow() method of Context return the current view context, for get the title bar of an Activity, android.id.id.title

View title = getWindow().findViewById(android.R.id.title);
View titleBar = (View) title.getParent();
titleBar.setBackgroundColor(Color.RED);` 

这篇关于如何改变标题栏的颜色在android的活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆