这个创建custome工具栏:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="@mipmap/top_bar_bg"
local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
local:popupTheme="@style/ThemeOverlay.AppCompat.Light"
/>
把这个活动
private Toolbar toolbar;
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
把这个清单
<activity
android:name=".activity.RegisterActivity"
android:label="@string/profile"
android:parentActivityName=".activity.HomeActivity"
>
与android:name
和012替换当前的活动用android:parentActivity
替换您的父级活动
而不是使用片段使用活动并使用自定义工具栏 –
[在使用片段时在Android导航抽屉图像和插入符号之间切换]的可能重复(http://stackoverflow.com/questions/ 17258020 /切换Android之间的导航,抽屉图像和向上时刻care-when-using-fragme) –