【问题标题】:How to remove this arrow in the Toolbar on mainActivity Layout?如何在 mainActivity 布局的工具栏中删除此箭头?
【发布时间】:2018-05-08 14:21:04
【问题描述】:

几周前,我添加了这个Toolbar。我需要它用于滑动标签布局。 但是如果我安装apk,左上角有一个后退箭头。

我不知道如何删除它。你能帮帮我吗?

如果您需要任何其他布局或课程,请询问我。我将编辑问题。

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>

<android.support.design.widget.CoordinatorLayout
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.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|enterAlways"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

    <android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:tabMode="fixed"
        app:tabGravity="fill"/>
</android.support.design.widget.AppBarLayout>

<android.support.v4.view.ViewPager
    android:id="@+id/viewpager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"  />
</android.support.design.widget.CoordinatorLayout>

这里是

styles.xml

<?xml version="1.0" encoding="utf-8"?>

<resources>

<style name="MyTheme" parent="MyTheme.Base">

</style>

<style name="MyTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

</resources>

【问题讨论】:

  • 请在提问前先搜索你的答案,我在google中输入了“android actionbar arrow remove”,答案在第一个链接上。
  • @barotia 90% 的答案都是错误的
  • 然后使用剩下的 10%。

标签: java android xml android-layout fragment


【解决方案1】:

鉴于箭头的存在,我假设您将Toolbar 设置为ActionBar

如果是这样,修复非常简单。只需调用

getActionBar().setDisplayHomeAsUpEnabled(false);

在您调用setActionBar(yourToolbar) 以确保没有空指针问题之后

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-20
    • 1970-01-01
    • 2018-03-03
    相关资源
    最近更新 更多