【问题标题】:Android Hide actionbar and ToolbarAndroid 隐藏操作栏和工具栏
【发布时间】:2016-01-03 09:29:29
【问题描述】:

在清单中我使用

minSdkVersion 14
targetSdkVersion 23

现在,我想隐藏主题:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="ir.pishguy.simpleadvancepagedesign">

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

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

</manifest>


<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="@style/Theme.AppCompat.Light">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowActionBar">false</item>
    </style>

</resources>

但我收到此错误:

    Caused by: java.lang.IllegalStateException: You need to use a 
Theme.AppCompat theme (or descendant) with this activity.

【问题讨论】:

    标签: android


    【解决方案1】:

    在活动中使用getSupportActionBar().hide();

    或片段中的getActivity.getSupportActionBar().hide();

    【讨论】:

      【解决方案2】:

      只需替换这个:

      &lt;style name="AppTheme" parent="@style/Theme.AppCompat.Light"&gt;

      用这个:

      &lt;style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"&gt;

      如果您想在 setSupportActionbar(Toolbar toolBar) 方法之后隐藏工具栏,请使用 getSupportActionbar().hide();

      希望对你有帮助!!!

      【讨论】:

        【解决方案3】:

        this link查看我的解决方案

        使用风格

        <style name="FullScreenTheme" parent="Theme.AppCompat.NoActionBar">
            <!-- ... -->
        </style>
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2014-03-18
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-02-02
          • 2023-03-27
          • 1970-01-01
          相关资源
          最近更新 更多