渐变风格 [英] Gradient styles

查看:191
本文介绍了渐变风格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Andr​​oid应用我已经隐藏了默认的标题栏,推出了TabView的,而在此TabView的的标签添加自己的标题栏。目前,我使用了android:ATTR / windowTitleStyle风格,这使得我的新标题栏看起来灰色和梯度。它看起来pretty的不错,但我的屏幕正在寻找pretty的灰度。我想通过这个标题栏不同的颜色渐变来调剂了一点东西。

什么是我在看吗?创建我自己的形象,并使用它吗? ?在Android:ATTR / windowTitleStyle风格似乎取决于您的自定义标题栏的高度扩展;所以我不知道它实际上是一个单一的形象。

我试图抛出的LinearLayout在它带着几分半透明的(例如:在进行颜色#800000FF),而渐变样式我有这样的LinearLayout身后消失

感谢您的帮助

更新:

每我的回答楼下,我已经想通了,我可以创建一个定义一个梯度一个XML文件,并使用它。这里面的LinearLayout(titlebar_gradient)工作正常,我有我的布局。然而,它不工作的最外侧的LinearLayout(background_gradient)。有人能告诉我为什么吗?据我所知,ListView控件应该是透明的......

 < XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
 机器人:方向=垂直
 机器人:layout_width =FILL_PARENT
 机器人:layout_height =FILL_PARENT
 机器人:背景=@可绘制/ background_gradient
 >
 < LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
  机器人:方向=横向
  机器人:layout_width =FILL_PARENT
  机器人:layout_height =47dip
  机器人:背景=@可绘制/ titlebar_gradient
  机器人:重力=中心>
  <的TextView
   机器人:layout_width =FILL_PARENT
   机器人:layout_height =WRAP_CONTENT
   机器人:layout_weight =1
   机器人:文本=项目
   风格=机器人:ATTR / windowTitleStyle
   机器人:以下属性来=5dip
   机器人:MAXLINES =1
   机器人:ellipsize =结束/>
 < / LinearLayout中>
    <的ListView
     机器人:ID =@ + ID / Android的:清单
     机器人:layout_width =FILL_PARENT
     机器人:layout_height =FILL_PARENT
  机器人:paddingTop =10dip
  机器人:可点击=假
    />
 <的TextView
     机器人:ID =@ + ID /安卓:空
     机器人:layout_width =FILL_PARENT
     机器人:layout_height =FILL_PARENT
    />
< / LinearLayout中>
 

解决方案

是啊,我也看到了一个例子给渐变颜色到的LinearLayout或按钮在本网站的http://android-$c$cs-examples.blogspot.com/2011/04/animated-customized-popup-transparent.html

In my Android application I've hidden the default title bar, introduced a TabView and added my own titlebar under that TabView's tabs. At the moment, I'm using the ?android:attr/windowTitleStyle style which makes my new titlebar look gray and gradient. It looks pretty good, but my screens are looking pretty grayscale. I'd like to spice things up a bit by making this titlebar a different color gradient.

What am I looking at here? Creating my own image and using it? The ?android:attr/windowTitleStyle style seems to expand depending on the height of your custom titlebar; so I'm not sure it's actually a single image.

I've attempted to throw a LinearLayout over it with a bit of translucency (ex: making the color #800000FF), but the gradient style I have behind this LinearLayout disappears.

Thanks for your help

Update:

Per my answer down below, I've figured out that I can create an XML file that defines a gradient and use that. It works fine inside a LinearLayout (titlebar_gradient) I have on my layout. However, it is not working on the outer-most LinearLayout (background_gradient). Could someone tell me why? As I understand it, the ListView should be transparent...

<?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>

解决方案

Yea i too saw an example for giving the gradient colors to the linearlayout or for the button on this site http://android-codes-examples.blogspot.com/2011/04/animated-customized-popup-transparent.html

这篇关于渐变风格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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