Мне нужно реализовать следующий actionBar:
Для этого хотел провести такую кастомизацию:
public boolean onCreateOptionsMenu(Menu menu) {
ActionBar actionBar = getActionBar();
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME);
actionBar.setCustomView(R.layout.custom_menu);
actionBar.setBackgroundDrawable(new ColorDrawable(Color.GRAY));
actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
TextView textView = (TextView) findViewById(R.id.actionbar_title);
textView.setText("title");
getMenuInflater().inflate(R.menu.menu_detail_view, menu);
return super.onCreateOptionsMenu(menu);
}
Вот custom_menu.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:layout_gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/actionbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textStyle="bold"
android:textColor="#ffffff"
android:textSize="18sp"
/>
И вот menu_detail_view.xml - пустой
В итоге получается, что текст по середине, а кнопки "home" нет. Как быть? Уже и не знаю что править...