android hide actionbar code example

Example 1: android java remove action bar

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

Example 2: android hide status bar and action bar daynamically

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
public class MainActivity extends AppCompatActivity {
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      requestWindowFeature(Window.FEATURE_NO_TITLE);
      getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
      setContentView(R.layout.activity_main);
   }
}

Example 3: hide elements android

//in your XML file:
android:visibility="gone" <-- hides

android:visibility="visible" <-- makes it visible

//or in java file:
textView.setVisibility(View.GONE);//makes it disappear

textView.setVisibility(View.VISIBLE);//makes it visible again

Tags:

Java Example