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:15

Heres a quick solution.

You find styles.xml and you change the base application theme to "Theme.AppCompat.NoActionBar" as shown below.

<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
    <!-- Customize your theme here. -->
</style>
查看更多
千与千寻千般痛.
3楼-- · 2019-01-01 09:15

You can force hide the action bar simply:

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

Just use your default theme.

查看更多
皆成旧梦
4楼-- · 2019-01-01 09:16

Don't use Holo theme and the Actionbar will disappear. This code is working for me on API 8+, with support lib v7:

<style name="NoActionBar" parent="@style/Theme.AppCompat.Light">
<item name="android:windowNoTitle">true</item>
</style>

set that theme for your activity:

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

and in your activity class.

It works even when it extends ActionBarActivity.

查看更多
墨雨无痕
5楼-- · 2019-01-01 09:18
<application
    .
    .
    android:theme="@android:style/Theme.Holo.Light.NoActionBar"
    . >

maybe this help you

查看更多
几人难应
6楼-- · 2019-01-01 09:18

The best way I found which gives custom themes and no action bar, is to create a SuperClass for all activities in my project and in it's onCreate() call the following line of code -

this.requestWindowFeature(Window.FEATURE_NO_TITLE);

It always work for me. The only issue in this approach is, you'll see action bar for a fraction of second when starting the app (Not the activity, the complete app).

查看更多
看风景的人
7楼-- · 2019-01-01 09:18

try this in your manifist

 <activity
        android:name=".MainActivity"
        android:theme="@android:style/Theme.Holo.NoActionBar"
        android:label="@string/app_name" >
查看更多
登录 后发表回答