사용자 정의 액션 바를 만들고 원하는대로 제목 배경색을 변경할 수 있습니다.
이 단계에 따라 이에 대한
만 할 수는 제목의 사용자 지정 셜록 줄을 만들 수 있습니다.
응용 프로그램의 title에 대한 별도의 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