カスタムアクションバーを作成して、タイトルバックグラウンドカラーを任意に変更することができます。
は、この手順に従います。このため
のみ可能タイトルのカスタムシャーロックバーを作成します。
アプリのタイトル用に個別のxmlファイルを作成します。
ファイルは次のように含まれている...このカスタムレイアウトで
、我々はカラーコードを使用して背景色を変更することができます。.. MainActivityについては
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>
かどのアクティビティをタイトルに追加しますか:
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");
sメソッド..
http://jgilfelt.github.io/android-actionbarstylegeneratorを使用して一連のリソースを生成し、まだ試していない関連性のあるものを参照してください。 – CommonsWare