主页应该有导航抽屉其他页面没有导航抽屉
显示插入符号 - >像这样
主页视图看起来像
fragment
视图如下所示:
see here for details Navigation drawer menu items selection snapshot
使用navigation drawer
开发应用程序我的主页上有导航抽屉我希望隐藏导航抽屉并显示操作栏主页按钮setHomeAsUpEnabled = true
而不是导航抽屉。
如何在我的应用程序中实现此逻辑?
如果有人知道这件事,请告诉我吗?
答案 0 :(得分:0)
启用Home back按钮使用以下代码。
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
答案 1 :(得分:0)
通过以下方式创建客户工具栏:
<?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
和
用android:parentActivity
答案 2 :(得分:0)
将其用于片段onCreateView或onResume ((AppCompatActivity) getActivity()).getSupportActionBar().setHomeAsUpIndicator(null);
中,这些片段将隐藏汉堡包并显示后退按钮