How to remove title bar from the android activity?

后端 未结 7 995
名媛妹妹
名媛妹妹 2020-12-23 01:54

Can someone please help me with the issue.I want my activity as full screen and want to remove title from the screen.I have tried several ways but not able to remove it.

7条回答
  •  清歌不尽
    2020-12-23 02:36

    you just add this style in your style.xml file which is in your values folder

    
    

    After that set this style to your activity class in your AndroidManifest.xml file

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

    Edit:- If you are going with programmatic way to hide ActionBar then use below code in your activity onCreate() method.

    if(getSupportedActionbar()!=null)    
         this.getSupportedActionBar().hide();
    

    and if you want to hide ActionBar from Fragment then

    getActivity().getSupportedActionBar().hide();
    

    AppCompat v7:- Use following theme in your Activities where you don't want actiobBar Theme.AppComat.NoActionBar or Theme.AppCompat.Light.NoActionBar or if you want to hide in whole app then set this theme in your in your AndroidManifest.

    In Kotlin:

    add this line of code in your onCreate() method or you can use above theme.

    if (supportActionBar != null)
            supportActionBar?.hide()
    

    i hope this will help you more.

提交回复
热议问题