2

私はこのSOの質問の指示に従いました:アクションバーのテキストを変更する方法

独自のタイトルバーを正常に作成できますが、レイアウトに背景色を適用すると、色がタイトルバー全体に広がりません。アンドロイドの灰色の背景色の残骸がまだあります。

これが私のXMLです:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="400px" 
  android:layout_height="fill_parent"
  android:orientation="horizontal" android:background="@color/solid_blue">

<ImageView android:id="@+id/logo" 
            android:layout_width="57px" 
            android:layout_height="wrap_content"
            android:background="@drawable/icon">

</ImageView>

<TextView 

  android:id="@+id/myTitle" 
  android:text="StockDroid by" 
  android:layout_width="fill_parent" 
  android:layout_height="fill_parent" 
  android:textColor="#FFFFFF"
   />
</LinearLayout>
4

1 に答える 1

2

残りのものは、コメントマンとしてそのリンク自体にあります。

編集:

ウィンドウタイトルのカスタムスタイルを設定しandroid:theme、アクティビティの属性によってマニフェストに設定するために見逃したもの。

res / values/styles.xmlファイルに次の2つのスタイルを作成する必要があります。

<style name="MyTheme" parent="android:Theme">
        <item name="android:windowTitleSize">50px</item>
        <item name="android:windowTitleBackgroundStyle">@style/WindowTitleBackground
        </item>

    </style>
<style name="WindowTitleBackground" parent="android:WindowTitleBackground">
        <item name="android:background">@android:color/transparent
        </item>
    </style>

次に、次のようなマニフェストのテーマとしてスタイルを設定する必要があります。

<activity android:name=".activity"
            android:label="@string/appname" android:theme="@style/MyTheme" />

それが役に立てば幸い。

于 2010-09-23T07:34:02.290 に答える