How to disable action bar permanently

2019-01-01 08:48发布

I can hide the action bar in honeycomb using this code:

getActionBar().hide();

But when the keyboard opens, and user copy-pastes anything, the action bar shows again. How can I disable the action bar permanently?

25条回答
旧时光的记忆
2楼-- · 2019-01-01 09:19

By setting activity theme in Manifest,

<activity
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
....
>
查看更多
余生请多指教
3楼-- · 2019-01-01 09:23

Make sure you create a new theme by changing the name of the default theme in the styles.xml file to:

 <style name="MyTheme" parent="android:Theme.Material.Light.NoActionBar">

and than change the theme from the drop-down under your main_activity.xml to whatever you called your theme.

查看更多
有味是清欢
4楼-- · 2019-01-01 09:24

I use the following code inside my onCreate function:

ActionBar actionBar = getSupportActionBar();
actionBar.hide();

Source: https://developer.android.com/guide/topics/ui/actionbar.html

查看更多
宁负流年不负卿
5楼-- · 2019-01-01 09:25

Type this code to your onCreate method before setContentView:

requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 0);
查看更多
高级女魔头
6楼-- · 2019-01-01 09:26

Under res -> values ->strings.xml

Change

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

To

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

查看更多
一个人的天荒地老
7楼-- · 2019-01-01 09:29
  protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   android.support.v7.app.ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.hide();
    }
    setContentView(R.layout.activity_main);
查看更多
登录 后发表回答