Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WindowActivityBar=false not working

Tags:

android

I'm writing an app which will be on embedded device, and I need to remove ActionBar alongside the TitleBar and ContentOverlay. I found a solution and inserted the following in my styles:

<style name="NoActionBar" parent="@android:style/Theme.Holo.Light">
        <item name="android:windowActionBar">false</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowFullscreen">true</item>
        <item name="android:windowContentOverlay">@null</item>
 </style>

and also add the line to my activity in AndroidManifest:

android:theme="@style/NoActionBar"

and in the end I got no title bar, no content overlay, however the ActionBar is still there. Please advice. I use android:theme="@android:style/Theme.Holo.Light" and my targetSdkVersion is 18.

like image 211
Constantine Samoilenko Avatar asked Aug 25 '16 07:08

Constantine Samoilenko


People also ask

What is windowActionBar in android?

android:windowActionBar denotes property for lollipop and above only. Where as windowActionBar denotes for all versions and is retrieved from support library. Follow this answer to receive notifications.

What is Toolbar android studio?

android.widget.Toolbar. A standard toolbar for use within application content. A Toolbar is a generalization of action bars for use within application layouts.


1 Answers

Small mistakes in XML can cause very strange problems,
which are not always reported accurately by the build process.
I tend to shy away from changing XML, when I can do it in java.
Java gives you more control.

programmatically remove action bar
----------------------------------
from normal activity

getActionbar().hide();
getActionbar().show();

if your using support activity

getSupportActionBar().hide();
getSupportActionBar().show();

and from the Fragment you can do it

getActivity().getActionbar().hide();
getActivity().getActionbar().show();

remove title bar
----------------

public class ActivityName extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // remove title
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.main);
    }
}

ActionBar ContentOverlay
------------------------
1) Request for actionbar overlay programmatically by calling

       getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);

// this 'requestFeature()' must be requested from your activity 'onCreate()' method
// before calling for 'setContentView(R.layout.my_layout)':
2) set the actionbar color by calling setBackgroundDrawable() like so:
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#00212121")) );
like image 168
Jon Goodwin Avatar answered Nov 15 '22 00:11

Jon Goodwin