android - 如何在android中隐藏工具栏?

标签 android android-studio android-layout

我真的是 android 新手,正在使用一个 google 模板开发一个小项目;带标签的标签式 Activity ...有没有办法隐藏标题部分 (tabbedExample) 并只保留标签?

enter image description here

样式.xml

  <resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

</resources>

list .xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="c.example.jinzunza.tabstoolbars">

    <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=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

最佳答案

你可以简单地隐藏工具栏,把它放在你的 Activity 中,放到 oncreate 方法中:

getSupportActionBar().hide();

关于android - 如何在android中隐藏工具栏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53342631/

相关文章:

android-studio - Android Studio 更新 : Some conflicts found in installation area (studio. exe |卸载.exe)

Android App UI设计: WhatsApp like Tabs

android - 如何在多行上方 float TextView

java - OTP 未从 firebase 代码中获取是正确的

android-如何扩展FragmentActivity和actionbaractivity

java - 抑制 "Log.v(TAG, ...)"内硬编码字符串的 Lint 警告

android - 什么是非嵌入式 Activity ,为什么不是 android :fitsSystemWindows work in it?

android - 如何在 Basic4Android 中创建圆角文本框

android - MultiChoiceModeListener android源码

Android BadParcelableException(Parcelable 协议(protocol)需要一个名为 CREATOR 的 Parcelable.Creator 对象)只有签名的 apk