I need to implement the following actionBar:
For this, I wanted to conduct such customization:
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); } Here is the 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" /> And menu_detail_view.xml - empty
The result is that the text is in the middle, but there is no "home" button. How to be? I do not even know what to rule ...