サポート ツールバーの [戻る] ボタンを中央に配置しようとすると問題が発生します。ActionBarActivity 内で使用しています。
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:toolbar="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
toolbar:popupTheme="@style/ThemeOverlay.AppCompat.Light"
toolbar:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
そして、Activity 内のナビゲーションを次のonCreate()
ように設定します。
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(R.string.title_activity_scanner);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
しかし、私が得ているのはこれです:
ご覧のとおり、戻るボタンの位置が間違っています
編集: 問題は 40 dp に設定するためのカスタム値にあるようです?attr/actionBarSize
が、代わりにタイトルが間違っていることがわかりました。