GithubHelp home page GithubHelp logo

sallysalem / fullscreen Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 251 KB

Show different cases to display fullscreen in android

License: Apache License 2.0

Kotlin 100.00%
android fullscreen fullscreen-mode

fullscreen's Introduction

FullScreen

There are different ways to display the fullscreen (without System bar or behind the System Bar)

Fullscreen without systembar

Immsersive mode

To Hide systemBars

WindowInsetsControllerCompat(window, window.decorView)

windowInsets.hide(WindowInsetsCompat.Type.systemBars())
windowInsets.systemBarsBehavior =
   WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE
Immersive.mov


Fullscreen behind the System Bar

Edge-To-Edge

Use setDecorFitsSystemWindows (Edge-To-Edge)

WindowCompat
    .setDecorFitsSystemWindows(
        window,
        false
    )








edge-to-edge.mov

WindowInsetsListener

Return CONSUMED from WindowInsetsListener

 ViewCompat.setOnApplyWindowInsetsListener(window.decorView) { _, _ ->
     WindowInsetsCompat.CONSUMED 
}

To reset

 ViewCompat.setOnApplyWindowInsetsListener(window.decorView, null)







Layout behavior using CoordinatorLayout

app:layout_behavior="@string/appbar_scrolling_view_behavior"
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <!-- Need for scrolling view behaviour -->
    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/black"
        android:fitsSystemWindows="true"
        android:visibility="gone"/>

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <!-- Add your layout -->
    </FrameLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

Set transperant statusbar

window.statusBarColor = Color.TRANSPARENT


Window insets

Window insets: is the area you display your screen

To get insets

 val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())

To change of the window insets for a view setOnApplyWindowInsetsListener

window_insets.mov

The system bars

The system bars: the status bar and the navigation bar

Hide system bar

WindowInsetsControllerCompat(
            window,
            window.decorView
        ).hide(WindowInsetsCompat.Type.systemBars())

Show system bar

WindowInsetsControllerCompat(
            window,
            window.decorView
        ).show(WindowInsetsCompat.Type.systemBars())

To control the visibility to one of system bars

Replace

WindowInsetsCompat.Type.systemBars() 

With

WindowInsetsCompat.Type.navigationBars()
Or 
WindowInsetsCompat.Type.statusBars()

fullscreen's People

Contributors

sallysalem avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.