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.
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.
android.widget.Toolbar. A standard toolbar for use within application content. A Toolbar is a generalization of action bars for use within application layouts.
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")) );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With