네, 제가 무지 쉬운걸 놓치고 몇시간 방황한 그 주제를 가지고 포스팅해보겠습니다.


액션바가 뭐나면요 


여기 myTitle 적힌 부분입니다.

대부분 제목이 왼쪽 정렬되있을텐데요.

꾸며보고 싶지 않으세요?

이제부터 꾸며 봅시다.

[custom_bar.xml]

<?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="@string/app_name"
android:textColor="#ffffff"
android:id="@+id/mytext"
android:textSize="22sp" />

</LinearLayout>

마치 액션바를 하나의 도화지로 보고 거기다 추가해주시면 됩니다.

아이콘을 넣을려면 ImageView 등을 쓰시면 되겠네요.

그후

[MainActivity.java]

import android.support.v7.app.ActionBar;
public class MainActivity extends AppCompatActivity {  
@Override

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getSupportActionBar().setCustomView(R.layout.custom_bar);
} catch (Exception e) {
System.out.println(e.getMessage());
}
setContentView(R.layout.activity_main);


네 일단 저 import를 꼭 해주시고요

그후 

getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getSupportActionBar().setCustomView(R.layout.custom_bar);

이 두 문장을 onCreate 바로아래에 추가해주시면 완료~