簡體   English   中英

片段工具欄后退按鈕未顯示

[英]Fragments toolbar back button not showing

我設置了自定義工具欄,並將“ setHomeButtonEnabled”和“ setDisplayHomeAsUpEnabled”設置為true,出於某種奇怪的原因,該工具欄正在顯示,但未顯示實際的后退按鈕。 我嘗試設置自定義圖標,並在更改片段時設置工具欄onclick,並且工具欄始終顯示,而backarrow卻不顯示。 可能是因為未調用我的注冊活動?

public class RegisterActivity extends BaseActivity {


@Override
public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    //setContentView(R.layout.activity_register);
    ButterKnife.bind(this);

    Toolbar toolbar = findViewById(R.id.my_toolbar);
    toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_material);

    setSupportActionBar(toolbar);
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

片段去的活動

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:background="@color/ghostWhiteColor"
    android:fitsSystemWindows="true"

    tools:context="com.vice.de.flu.activity.RegisterActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.v7.widget.Toolbar
            android:id="@+id/my_toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/holo_blue_light"/>
    </android.support.design.widget.AppBarLayout>


    <!--wizard>-->
    <FrameLayout
        android:id="@+id/fragment_register"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</android.support.design.widget.CoordinatorLayout>

我的清單

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".activity.MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".activity.RegisterActivity"
        android:windowSoftInputMode="adjustPan|adjustResize">

    </activity>
</application>
<android.support.v7.widget.Toolbar
   android:id="@+id/my_toolbar"
   android:layout_width="match_parent"
   android:layout_height="?attr/actionBarSize"
   android:background="@color/holo_blue_light"
   app:navigationIcon="@drawable/back_navigation_icon" />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM