Android 渐变样式

Android 渐变样式,android,gradient,titlebar,android-titlebar,Android,Gradient,Titlebar,Android Titlebar,在我的Android应用程序中,我隐藏了默认的标题栏,引入了一个选项卡视图,并在该选项卡视图的选项卡下添加了我自己的标题栏。目前,我正在使用?android:attr/windowTitleStyle样式,这使我的新标题栏看起来是灰色和渐变的。它看起来不错,但我的屏幕看起来很灰阶。我想通过使这个标题栏有不同的颜色渐变来增加一些趣味 我在看什么?创建自己的图像并使用它??android:attr/windowTitleStyle样式似乎根据自定义标题栏的高度而扩展;所以我不确定这是不是一张照片 我

在我的Android应用程序中,我隐藏了默认的标题栏,引入了一个选项卡视图,并在该选项卡视图的选项卡下添加了我自己的标题栏。目前,我正在使用?android:attr/windowTitleStyle样式,这使我的新标题栏看起来是灰色和渐变的。它看起来不错,但我的屏幕看起来很灰阶。我想通过使这个标题栏有不同的颜色渐变来增加一些趣味

我在看什么?创建自己的图像并使用它??android:attr/windowTitleStyle样式似乎根据自定义标题栏的高度而扩展;所以我不确定这是不是一张照片

我曾尝试在其上方添加一个带有一点半透明的线性布局(例如:制作颜色#800000 ff),但我在该线性布局后面的渐变样式消失了

谢谢你的帮助

更新:

根据我下面的答案,我发现我可以创建一个定义渐变的XML文件并使用它。它在我的布局上的线性布局(标题栏梯度)中运行良好。但是,它不适用于最外层的线性布局(背景梯度)。有人能告诉我为什么吗?据我所知,ListView应该是透明的

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:background="@drawable/background_gradient"
 >
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="horizontal"
  android:layout_width="fill_parent"
  android:layout_height="47dip"
  android:background="@drawable/titlebar_gradient"
  android:gravity="center">
  <TextView
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:layout_weight="1"
   android:text="Item"
   style="?android:attr/windowTitleStyle"
   android:paddingLeft="5dip"
   android:maxLines="1"
   android:ellipsize="end" />
 </LinearLayout>
    <ListView
     android:id="@+id/android:list"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
  android:paddingTop="10dip"
  android:clickable="false"
    />
 <TextView
     android:id="@+id/android:empty"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
    />
</LinearLayout>

我现在明白我的问题了

我在drawables文件夹中创建了一个XML文件,如下所示

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
       <gradient
        android:startColor="#00CC66"
        android:endColor="#009966"
        android:angle="270"/>
    /shape>

/形状>

在我的工具栏中,我将背景设置为此可绘制。不幸的是,这不适用于我整个布局的背景:(