0
私はカスタムツールバーを表示し、他のフラグメントに移動するとホーム(ハンバーガー)アイコンと戻る矢印アイコンを表示したいと思います。カスタムアンドロイドツールバーの戻るボタンが表示されない
ホームボタンが表示されますが、戻る矢印は表示されません。
mvvmcrossを使用してマイアプリ、iはフラグメントを管理メインホストの活動、持っている:
[Activity()]
public class MainView : MvxCachingFragmentCompatActivity<MainViewModel>
{
private DrawerLayout _drawer;
private MvxActionBarDrawerToggle _drawerToggle;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.MainView);
var _toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
_toolbar.SetNavigationIcon(Resource.Drawable.back_arrow);
SetSupportActionBar(_toolbar);
SupportActionBar.SetDisplayHomeAsUpEnabled(true);
SupportActionBar.SetDisplayShowHomeEnabled(true);
SupportActionBar.SetDisplayShowTitleEnabled(false);
_drawer = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
_drawer.SetStatusBarBackgroundColor(Resource.Color.dark_gray);
_drawerToggle = new MvxActionBarDrawerToggle(this, _drawer, Resource.String.open_menu, Resource.String.close_menu);
_drawer.AddDrawerListener(_drawerToggle);
_drawerToggle.SyncState();
}
//...
}
ホストレイアウト:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">
<include layout="@layout/toolbar"/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<!-- The main content view -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<!-- The navigation drawer -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:orientation="vertical">
<FrameLayout
android:id="@+id/menu_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
とツールバーのレイアウト:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/toolbarTitle"
android:maxLines="1"
android:textSize="16sp"
android:text="My title"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="left"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp" />
</LinearLayout>
</RelativeLayout>
ととのこのすべて私はハンバーガーのアイコンを持っている、それは戻って矢印になっていない、または私のカスタムバックの矢印は、私が他の断片。 SupportActionBarプロパティのカスタムバリエーションとカスタム戻るボタンの設定を試しましたが、結果は同じです。どうすればこれを達成できますか?断片ホストクラスで
、私はフラグメントが変更されたときに、イベントを処理、およびフラグメントの種類に応じて、ツールバーに戻って表示したり、ホームボタン: