Hide or remove Action Bar on specific Activity | A

2019-05-08 01:55发布

How I can remove Action Bar on specific activity not for all application, for example I have Sign Up activity and for this activity I want to remove Action Bar

5条回答
Lonely孤独者°
2楼-- · 2019-05-08 02:33

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

查看更多
在下西门庆
3楼-- · 2019-05-08 02:38

from within your activity:

getActionBar().hide();

or

getSupportActionBar().hide();

I would suggest to migrate to ToolBar, new Android API for the same purpose. The main benefit of ToolBar is that you can treat it like other views, it guarantees to you a more flexible approach.

查看更多
淡お忘
4楼-- · 2019-05-08 02:40

In your AndroidManifest.xml use NoActionBar theme for your Activity like this:

<activity android:name=".SignUpActivity"
          android:theme="@style/AppTheme.NoActionBar"/>

and in your styles.xml

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>
查看更多
何必那么认真
5楼-- · 2019-05-08 02:40

If you have an ActionBar, you can use getActionBar().hide();
If you have a SupportActionBar, you can use getSupportActionBar().hide();

查看更多
forever°为你锁心
6楼-- · 2019-05-08 02:41

Remove Action Bar on specific Activity go to Activity java file here your Activity class extends with AppCompatActivity remove the AppCompatActivity and extends with Activity and go to xml file and select Theme NoTitleBar or go to Manifests file select your Activity and add Theme on your Activity android:theme="@android:style/Theme.NoTitleBar"/>

查看更多
登录 后发表回答