0

非常に薄い灰色から「ほぼ白」までのグラデーションカラーを作成する方法を見つけようとしています。例として、Android 用の ebuddy を参照できます。あなたの「仲間」はグラデーションカラーのリストにあります。

これはアンドロイドでどのように行われますか? aarrggbb を使用する必要があると思いますよね?

4

2 に答える 2

2

GradientDrawables を作成して Android にグラデーションを作成できます。次に例を示します。

<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 に答える