Android的梯度应用程序标题栏 [英] Android Gradient Application Title Bar

查看:159
本文介绍了Android的梯度应用程序标题栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  <一href="http://stackoverflow.com/questions/6115715/how-do-i-programmatically-set-the-background-color-gradient-on-a-custom-title-ba">How我编程设置背景颜色渐变的自定义标题栏?

我想使用的应用程序标题栏的渐变色。我该怎么办呢?

I want to use gradient color in application title bar. How can I do it?

在此先感谢。

推荐答案

所有的人都在试图用自定义标题作为这一要求。

All people are trying to use Custom title for this requirement.

我不使用自定义的标题来实现这一点。的setContentView后只需要用下面code。在您的活动的onCreate()()。

I achieved this without using custom title. Just use below code in your activity's onCreate() after setContentView().

GradientDrawable gd = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] {Color.RED,Color.GREEN});
View title = getWindow().findViewById(android.R.id.title);
View titleBar = (View) title.getParent();
titleBar.setBackgroundDrawable(gd);

享受以上code。下面的图片是屏幕截图我用渐变的颜色作为标题栏背景的应用程序的。

Enjoy with above code. Below image is screen shot of my app with gradient color as title bar background.

这篇关于Android的梯度应用程序标题栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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