首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >渐变样式

渐变样式
EN

Stack Overflow用户
提问于 2010-08-10 23:46:31
回答 1查看 13.2K关注 0票数 7

在我的Android应用程序中,我隐藏了默认的标题栏,引入了一个TabView,并在TabView的标签下添加了我自己的标题栏。目前,我使用的是?android:attr/windowTitleStyle样式,它使我的新标题栏看起来灰色和渐变。它看起来很不错,但我的屏幕看起来相当灰阶。我想把这个标题栏改成不同的颜色渐变,让它更有趣一点。

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

我试图在它上面添加一个带有一点半透明的LinearLayout (例如:使颜色#800000FF),但是我在这个LinearLayout后面的渐变样式消失了。

谢谢你的帮忙

更新:

根据我下面的回答,我已经知道我可以创建一个定义渐变的XML文件并使用它。它在我的布局中的LinearLayout (titlebar_gradient)中工作得很好。但是,它不能在最外层的LinearLayout (background_gradient)上工作。有人能告诉我为什么吗?据我所知,ListView应该是透明的……

代码语言:javascript
运行
复制
<?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>
EN

回答 1

Stack Overflow用户

发布于 2010-08-11 00:02:48

我现在明白我的问题了。

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

代码语言:javascript
运行
复制
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
       <gradient
        android:startColor="#00CC66"
        android:endColor="#009966"
        android:angle="270"/>
    /shape>

在我的工具栏中,我设置了这个可绘制的背景。

票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3450801

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档