Hi i want disable the status bar in an java app android, like when the user pull down the bar doesnt go down
Hi i want disable the status bar in an java app android, like when the user pull down the bar doesnt go down
Hello bro use This one!
Use this code for hiding the status bar in your app and easy to use
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
If what u want is full screen activity, use this
public class sample extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setFullScreen();
//add your code
}
private void setFullScreen() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R){
getWindow().getInsetsController().hide(WindowInsets.Type.statusBars() | WindowInsets.Type.statusBars());
getWindow().getInsetsController().setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
}else {
getWindow().setFlags(LayoutParams.FLAG_FULLSCREEN,LayoutParams.FLAG_FULLSCREEN);
}
}
}
If you're saying that u don't status bar to open, then that isn't possible.
You can't show and hide native status bar of android, the system doesn't allow you to do that. But you can create your own customized status, then you can show it and hide it as you want. Here and example: custom_status.xml
<com.google.android.material.card.MaterialCardView
android:id="@+id/mToolbar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:backgroundTint="@color/white"
app:cardCornerRadius="0dp"
app:cardElevation="0dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/textView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginHorizontal="15dp"
android:layout_marginVertical="15dp"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:paddingBottom="2dp"
android:textColor="@color/black"
android:textSize="32sp"
app:layout_constraintBottom_toBottomOf="@+id/backButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/backButton"
app:layout_constraintTop_toTopOf="@+id/backButton" />
<ImageView
android:id="@+id/backButton"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginStart="15dp"
android:layout_marginTop="20dp"
android:background="@drawable/ic_circle_solid"
android:backgroundTint="@color/quantum_grey100"
android:padding="7dp"
android:src="@drawable/ic_baseline_arrow_back_24"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
in java code
public void onScrollStateChanged(AbsListView view, int scrollState) {
final ListView lw = getListView();
if (view.getId() == lw.getId()) {
final int currentFirstVisibleItem = lw.getFirstVisiblePosition();
if (currentFirstVisibleItem > mLastFirstVisibleItem) {
mIsScrollingUp = false;
//mToolbar_container visible
} else if (currentFirstVisibleItem < mLastFirstVisibleItem) {
mIsScrollingUp = true;
//mToolbar_container gone
}
}
}