7

この質問はすでに尋ねられていることは知っていますが、それを機能させる方法がわかりません。タイトル バーの背景を変更したい。

アプリケーションや背景のスタイルについて、他に何も変更したくありません。

このサイトのさまざまな投稿をたどりましたが、どれも満足のいく結果をもたらさないようです.

私はそれが設定するのと同じくらい簡単だと思うだろう

<style name="AppTheme" parent="AppBaseTheme">
<item name="android:windowTitleBackgroundStyle">@drawable/backrepeat</item>
</style>

styles.xml 内

しかし、これは何の変化も与えません。

完全を期すために、以下は私のバックリピートファイルです

<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/bg_diamonds"
android:tileMode="repeat"
android:dither="true" 
/>

そしてmanifest.xmlのコード

<application
android:allowBackup="true"
android:icon="@drawable/maxmm_start_icon"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
4

2 に答える 2

24

アクティビティの作成時に使用できます。(作成時)

ActionBar bar = getActionBar();
//for color
bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#00C4CD")));
//for image
bar.setBackgroundDrawable(getResources().getDrawable(R.drawable.settings_icon));
于 2013-10-01T09:16:47.080 に答える
10

このコードを使用してタイトルの色を変更するには、 oncreate() に次の行を追加します。

ColorDrawable colorDrawable = new ColorDrawable(Color.parseColor("#20a780"));
    getSupportActionBar().setBackgroundDrawable(colorDrawable);
于 2014-12-16T06:00:25.510 に答える