Android Studio - Action Bar remove

混江龙づ霸主 提交于 2019-12-03 05:52:48

问题


I'm trying to remove/disable the ActionBar. I tried to put in the Manifest:

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

and it doesn't work. It doesn't remove the ActionBar. Please help me. Thanks.


回答1:


in your oncreate() method use this

getActionBar().hide();

If your minSdkVersion is 10 or lower, instead use:

getSupportActionBar().hide();



回答2:


I had this issue too. I went to styles.xml and changed

parent="Theme.AppCompat.Light.DarkActionBar" 

to

parent="Theme.AppCompat.Light.NoActionBar"

and that removed it from all my activities.




回答3:


You can try this. It works for me

Add it in style.xml

<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.DarkActionBar">
      <item name="windowActionBar">false</item>
      <item name="windowNoTitle">true</item>
      <item name="android:windowFullscreen">true</item>
</style>

and use the style at manifest.xml.

android:theme="@style/AppTheme.NoActionBar"



回答4:


getActionBar().hide();

I think this should work.




回答5:


For android studio You can go to styles.xml and change parent="Theme.AppCompat.Light.DarkActionBar" to parent="Theme.AppCompat.Light.NoActionBar" and in Eclipse it can be changed in manifest file

  <activity
        android:name="com.ExcellenceTech.webview.MainActivity"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen" >



回答6:


In AndroidManifest.xml and acitivity section put this code.

android:theme="@style/Theme.AppCompat.Light.NoActionBar"



回答7:


You hide action bar by with different ways.

1.action bar hidden through the manifest xml file (non Java Programming), then the easy way is to add the following attribute in Activity tag:

 android:theme="@style/Theme.NoActionBar"

If custom Theme is created then it is convenient to create another style extending the custom theme.

 <item name="android:windowActionBar">false</item>
 <item name="android:windowNoTitle">true</item>

or

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

getSupportActionBar().hide(); 
  or 
getActionBar().hide();



回答8:


getActionBar().hide();

or

getSupportActionBar().hide();

But the change might not appear in the xml design.



来源:https://stackoverflow.com/questions/24742732/android-studio-action-bar-remove

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!