7

私の Android アプリケーションでは、デフォルトのタイトル バーを非表示にし、TabView を導入し、その TabView のタブの下に独自のタイトル バーを追加しました。現時点では、新しいタイトルバーをグレーとグラデーションに見せる ?android:attr/windowTitleStyle スタイルを使用しています。見た目はかなり良いですが、私の画面はかなりグレースケールに見えます。このタイトルバーを別の色のグラデーションにすることで、少しスパイスを効かせたいと思います。

私はここで何を見ていますか?独自のイメージを作成して使用しますか? ?android:attr/windowTitleStyle スタイルは、カスタム タイトルバーの高さに応じて拡張されるようです。そのため、実際に単一の画像であるかどうかはわかりません。

少し半透明で LinearLayout を投げようとしましたが (例: 色を #800000FF にする)、この LinearLayout の背後にあるグラデーション スタイルが消えます。

ご協力いただきありがとうございます

アップデート:

以下の私の回答によると、グラデーションを定義する XML ファイルを作成して使用できることがわかりました。レイアウトにある LinearLayout (titlebar_gradient) 内で正常に動作します。ただし、最も外側の LinearLayout (background_gradient) では機能しません。誰かが理由を教えてもらえますか? 私が理解しているように、ListViewは透明でなければなりません...

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

1 に答える 1

9

私は今私の問題を理解しています。

drawables フォルダーに、次のような XML ファイルを作成しました。

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
       <gradient
        android:startColor="#00CC66"
        android:endColor="#009966"
        android:angle="270"/>
    /shape>

ツールバーで、背景をこのドローアブルに設定しました。

于 2010-08-10T16:02:48.280 に答える