0

试图弄清楚如何在非常浅的灰色上制作渐变色到“几乎是白色”。例如,我可以参考 ebuddy for android。你的“伙伴”在一个渐变色的列表中。

这是如何在android中完成的?我相信它应该使用 aarrggbb 对吗?

4

2 回答 2

2

你可以让 GradientDrawables 在 android 中创建 Gradients,例如:

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
  <gradient
      android:startColor="#FF808080"
      android:endColor="#FFFFFFFF"
      android:angle="270"/>
</shape>
于 2012-06-19T04:23:51.027 回答
0

您可以在 res 文件夹中的 drawable 文件夹中创建此 rectangle.xml 文件:(这里的颜色正是您想要的颜色)

  <?xml version="1.0" encoding="UTF-8"?>
  <shape xmlns:android="http://schemas.android.com/apk/res/android"  android:shape="rectangle"  type="rectangle">

  <gradient android:angle="90" android:startColor="#a3a3a3" android:centerColor="#cfcfcf" android:endColor="#f0f0f0"/>

现在您可以通过在 style.xml 文件中定义它来将其用作屏幕的背景,如下所示:

    <style name="screenBackground">
        <item name="android:paddingLeft">5dip</item>
        <item name="android:paddingTop">2dip</item>
        <item name="android:paddingRight">5dip</item>
        <item name="android:paddingBottom">2dip</item>
        <item name="android:background">@drawable/rectangle</item>
        <item name="android:layout_marginBottom">15dp</item>
    </style>

现在在您的 main.xml 文件中使用它:

   <?xml version="1.0" encoding="UTF-8"?>
    <LinearLayout android:id="@+id/header"
      android:layout_width="fill_parent" android:layout_height="wrap_content"
      xmlns:android="http://schemas.android.com/apk/res/android" style="@style/screenBackground">

       // All your other elements in the xml file go here.

     </LinearLayout>
于 2012-06-19T06:13:02.910 回答