간단하게 정리하면
In Activity, in onCreate() method:
1 2 |
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); getSupportActionBar().setCustomView(R.layout.abs_layout); |
In XML, (abs_layout.xml)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="my Title" android:textColor="#ffffff" android:id="@+id/mytext" android:textSize="18sp" /> </LinearLayout> |
참고 사이트 : http://stackoverflow.com/questions/12387345/how-to-center-align-the-actionbar-title-in-android