カスタムアクションバーを作成し、タイトルの背景色を好きなように変更できます。
次の手順に従います。
タイトル用のカスタム シャーロック バーを作成する場合にのみ可能です。
アプリのタイトル用に別の xml ファイルを作成します。
そのファイルには次のようなものが含まれています..
このカスタム レイアウトでは、カラー コードを使用して背景色を変更できます。
header_sherlock.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="3"
android:background="#008000"
>
<TextView
android:id="@+id/header_tvleft"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="left"
android:layout_marginTop="@dimen/margintop"
android:clickable="true"
android:paddingLeft="@dimen/layoutpaddingleft"
android:text="Textview"
android:textColor="#ffffff"
android:textSize="@dimen/header_leftbtn"
/>
<TextView
android:id="@+id/header_tvcenter"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:layout_marginTop="@dimen/margintop"
android:layout_marginRight="@dimen/sherlockpaddingright"
android:layout_marginLeft="@dimen/sherlockpaddingleft"
android:text="Textview"
android:textColor="#ffffff"
android:textStyle="bold"
android:textSize="@dimen/header_title"
/>
<TextView
android:id="@+id/header_tvright"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="right"
android:layout_marginTop="@dimen/margintop"
android:clickable="true"
android:paddingRight="@dimen/layoutpaddingright"
android:text="Textview"
android:textColor="#ffffff"
android:textSize="@dimen/header_rightbtn"
/>
</LinearLayout>
MainActivity または title を追加するアクティビティの場合:
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getSupportActionBar().setCustomView(R.layout.header_sherlock);
header_tvleft = (TextView) findViewById(R.id.header_tvleft);
header_tvleft.setText("LeftTitleName");
header_tvcenter = (TextView) findViewById(R.id.header_tvcenter);
header_tvcenter.setText("CenterTitleName");
header_tvright = (TextView) findViewById(R.id.header_tvright);
header_tvright.setText("RightTitleName");
この方法を試してみてください..