android – 渐变样式

前端之家收集整理的这篇文章主要介绍了android – 渐变样式前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在我的 Android应用程序中,我隐藏了默认标题栏,引入了TabView并在TabView的选项卡下添加了我自己的标题栏.目前,我正在使用?android:attr / windowTitleStyle样式,这使我的新标题显示为灰色和渐变.它看起来不错,但我的屏幕看起来非常灰度.我想通过使这个标题栏成为不同的颜色渐变来增加一些东西.

我在这看什么?创建我自己的图像并使用它? ?android:attr / windowTitleStyle样式似乎会根据自定义标题栏的高度进行扩展;所以我不确定它实际上是一个单一的图像.

我尝试用一​​点半透明的方式抛出一个LinearLayout(例如:使颜色为#800000FF),但我在此LinearLayout后面的渐变样式消失了.

谢谢你的帮助

更新:

根据我在下面的回答,我发现我可以创建一个定义渐变的XML文件并使用它.它在我的布局上的LinearLayout(titlebar_gradient)中工作正常.但是,它不适用于最外层的LinearLayout(background_gradient).有人能告诉我为什么吗?据我了解,ListView应该是透明的……

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:orientation="vertical"
  4. android:layout_width="fill_parent"
  5. android:layout_height="fill_parent"
  6. android:background="@drawable/background_gradient"
  7. >
  8. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  9. android:orientation="horizontal"
  10. android:layout_width="fill_parent"
  11. android:layout_height="47dip"
  12. android:background="@drawable/titlebar_gradient"
  13. android:gravity="center">
  14. <TextView
  15. android:layout_width="fill_parent"
  16. android:layout_height="wrap_content"
  17. android:layout_weight="1"
  18. android:text="Item"
  19. style="?android:attr/windowTitleStyle"
  20. android:paddingLeft="5dip"
  21. android:maxLines="1"
  22. android:ellipsize="end" />
  23. </LinearLayout>
  24. <ListView
  25. android:id="@+id/android:list"
  26. android:layout_width="fill_parent"
  27. android:layout_height="fill_parent"
  28. android:paddingTop="10dip"
  29. android:clickable="false"
  30. />
  31. <TextView
  32. android:id="@+id/android:empty"
  33. android:layout_width="fill_parent"
  34. android:layout_height="fill_parent"
  35. />
  36. </LinearLayout>

解决方法

是的,我也看到了一个例子,它给渐变颜色提供了线性布局或者这个网站上的按钮 http://android-codes-examples.blogspot.com/2011/04/animated-customized-popup-transparent.html

猜你在找的Android相关文章