Example usage for android.view View SYSTEM_UI_FLAG_LAYOUT_STABLE

List of usage examples for android.view View SYSTEM_UI_FLAG_LAYOUT_STABLE

Introduction

In this page you can find the example usage for android.view View SYSTEM_UI_FLAG_LAYOUT_STABLE.

Prototype

int SYSTEM_UI_FLAG_LAYOUT_STABLE

To view the source code for android.view View SYSTEM_UI_FLAG_LAYOUT_STABLE.

Click Source Link

Document

Flag for #setSystemUiVisibility(int) : When using other layout flags, we would like a stable view of the content insets given to #fitSystemWindows(Rect) .

Usage

From source file:com.hacktx.android.activities.CheckInActivity.java

private void setupStatusBar() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
            && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        setTranslucentStatusFlag(true);//  w  w  w. j  a  v a  2s.  c  o m
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setTranslucentStatusFlag(false);
        getWindow().setStatusBarColor(Color.TRANSPARENT);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        final View scrollView = findViewById(R.id.scrollView);
        final int bigMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24,
                getResources().getDisplayMetrics());

        ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) scrollView.getLayoutParams();
        p.setMargins(0, bigMargin, 0, 0);
        scrollView.requestLayout();
    }
}

From source file:com.avolatile.randomdaily.IntroductionActivity.java

@Override
protected void onResume() {

    /* The following code will enable immersive mode for the introduction screen
     * for devices running on Android 3.0 Honeycomb or higher. This will effectively
     * enable immersive mode all of the app's instances as the app is only compatible
     * with devices running on Android 4.1 Jelly Bean or higher */

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        View decorView = getWindow().getDecorView();
        decorView.setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
    }//from   w w  w.j  a v a 2 s.com

    super.onResume();
}

From source file:net.nurik.roman.formwatchface.CompanionWatchFaceConfigActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().getDecorView()/*from  w w  w .ja va 2s. c o  m*/
            .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
    setContentView(R.layout.config_activity);

    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    // Set up general chrome
    ImageButton doneButton = (ImageButton) findViewById(R.id.done_button);
    doneButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });

    ScrimInsetsFrameLayout scrimInsetsFrameLayout = (ScrimInsetsFrameLayout) findViewById(
            R.id.scrim_insets_frame_layout);
    scrimInsetsFrameLayout.setOnInsetsCallback(new ScrimInsetsFrameLayout.OnInsetsCallback() {
        @Override
        public void onInsetsChanged(Rect insets) {
            findViewById(R.id.chrome_container).setPadding(0, insets.top, 0, 0);
        }
    });

    // Set up theme list
    mMainClockContainerView = (ViewGroup) ((ViewGroup) findViewById(R.id.clock_container)).getChildAt(0);
    mMainClockView = (FormClockView) mMainClockContainerView.findViewById(R.id.clock);

    mAnimateClockContainerView = (ViewGroup) ((ViewGroup) findViewById(R.id.clock_container)).getChildAt(1);
    mAnimateClockView = (FormClockView) mAnimateClockContainerView.findViewById(R.id.clock);

    mAnimateClockContainerView.setVisibility(View.INVISIBLE);

    setupThemeList();
    String themeId = mSharedPreferences.getString(ConfigHelper.KEY_THEME, Themes.DEFAULT_THEME.id);
    updateUIToSelectedTheme(themeId, false);

    registerSharedPrefsListener();

    // Set up complications config fragment
    mConfigComplicationsFragment = (ConfigComplicationsFragment) getFragmentManager()
            .findFragmentById(R.id.config_complications_container);
    if (mConfigComplicationsFragment == null) {
        mConfigComplicationsFragment = new ConfigComplicationsFragment();
        getFragmentManager().beginTransaction()
                .add(R.id.config_complications_container, mConfigComplicationsFragment).commit();
    }

    // Set up tabs/pager
    final ViewPager pager = (ViewPager) findViewById(R.id.view_pager);
    pager.setPageMargin((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16,
            getResources().getDisplayMetrics()));

    SimplePagerHelper helper = new SimplePagerHelper(this, pager);
    helper.addPage(R.string.title_theme, R.id.config_theme_container);
    helper.addPage(R.string.title_complications, R.id.config_complications_container);

    SlidingTabLayout slidingTabLayout = (SlidingTabLayout) findViewById(R.id.tabs);
    slidingTabLayout.setCustomTabView(R.layout.tab_indicator, android.R.id.text1);

    Resources res = getResources();
    slidingTabLayout.setSelectedIndicatorColors(res.getColor(R.color.tab_selected_strip));
    slidingTabLayout.setViewPager(pager);

    slidingTabLayout.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            super.onPageScrolled(position, positionOffset, positionOffsetPixels);
            float translationX = -pager.getWidth();
            if (position == 0) {
                translationX = -positionOffsetPixels;
            }
            mMainClockView.setTranslationX(translationX);
            mAnimateClockView.setTranslationX(translationX);
        }
    });
}

From source file:liam.franco.selene.activities.AboutActivity.java

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_about);
    ButterKnife.bind(this);
    App.BUS.register(this);

    setSupportActionBar(toolbar);/*from   w  w  w.j  a  v  a 2  s  .  c  o  m*/
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowHomeEnabled(true);
        getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_close_white_24dp);
    }

    UIUtils.setTranslucentNavigationFlag(this, true);
    UIUtils.setTranslucentStatusFlag(this, true);

    parentLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);

    parentLayout.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            int navBarHeight = UIUtils.getNavigationBarHeight(App.CONTEXT);

            // 1 = portrait, 2 = landscape
            int orientation = App.RESOURCES.getConfiguration().orientation;

            ViewGroup.MarginLayoutParams bar = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams();
            bar.topMargin += insets.getSystemWindowInsetTop();
            bar.rightMargin += insets.getSystemWindowInsetRight();
            toolbar.setLayoutParams(bar);

            // making sure it's all inside bounds because of our transparent status and nav bars
            scrollableLayout.setPadding(scrollableLayout.getPaddingLeft(), scrollableLayout.getPaddingTop(),
                    scrollableLayout.getPaddingRight()
                            + (orientation == 1 ? insets.getSystemWindowInsetRight() : navBarHeight),
                    scrollableLayout.getPaddingBottom()
                            + (orientation == 1 ? navBarHeight : insets.getSystemWindowInsetBottom()));

            parentLayout.setOnApplyWindowInsetsListener(null);
            return insets.consumeSystemWindowInsets();
        }
    });

    liamList.addItemDecoration(new SimpleDividerItemDecoration(this));
    liamAdapter = new FastItemAdapter<>();
    liamList.setLayoutManager(new UnscrollableLinearLayoutManager(this));
    liamList.setAdapter(liamAdapter);

    franciscoList.addItemDecoration(new SimpleDividerItemDecoration(this));
    franciscoAdapter = new FastItemAdapter<>();
    franciscoList.setLayoutManager(new UnscrollableLinearLayoutManager(this));
    franciscoList.setAdapter(franciscoAdapter);

    libsList.addItemDecoration(new SimpleDividerItemDecoration(this));
    libsAdapter = new FastItemAdapter<>();
    libsList.setLayoutManager(new UnscrollableLinearLayoutManager(this));
    libsList.setAdapter(libsAdapter);

    mutateMoreList.addItemDecoration(new SimpleDividerItemDecoration(this));
    mutateMoreAdapter = new FastItemAdapter<>();
    mutateMoreList.setLayoutManager(new UnscrollableLinearLayoutManager(this));
    mutateMoreList.setAdapter(mutateMoreAdapter);

    initAboutEntries();
}

From source file:us.phyxsi.gameshelf.ui.HomeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    ButterKnife.bind(this);

    drawer.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);

    setActionBar(toolbar);//ww  w  .  ja  va  2  s.c  o  m
    if (savedInstanceState == null) {
        animateToolbar();
    }

    bggPrefs = BGGPrefs.get(this);
    dataManager = new DataManager(this) {
        @Override
        public void onDataLoaded(List<? extends Boardgame> data) {
            adapter.addAndResort(data);
            checkEmptyState();
        }
    };
    adapter = new FeedAdapter(this, HomeActivity.this, dataManager, columns);
    grid.setAdapter(adapter);
    layoutManager = new GridLayoutManager(this, columns);
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            return adapter.getItemColumnSpan(position);
        }
    });
    grid.setLayoutManager(layoutManager);
    grid.addOnScrollListener(gridScroll);
    //        grid.addOnScrollListener(new InfiniteScrollListener(layoutManager) {
    //            @Override
    //            public void onLoadMore() {
    //                // TODO: Load more items
    //            }
    //        });
    grid.setHasFixedSize(true);

    // drawer layout treats fitsSystemWindows specially so we have to handle insets ourselves
    drawer.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            // inset the toolbar down by the status bar height
            ViewGroup.MarginLayoutParams lpToolbar = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams();
            lpToolbar.topMargin += insets.getSystemWindowInsetTop();
            lpToolbar.rightMargin += insets.getSystemWindowInsetRight();
            toolbar.setLayoutParams(lpToolbar);

            // inset the grid top by statusbar+toolbar & the bottom by the navbar (don't clip)
            grid.setPadding(grid.getPaddingLeft(),
                    insets.getSystemWindowInsetTop() + ViewUtils.getActionBarSize(HomeActivity.this),
                    grid.getPaddingRight() + insets.getSystemWindowInsetRight(), // landscape
                    grid.getPaddingBottom());

            // inset the fab for the navbar
            ViewGroup.MarginLayoutParams lpFab = (ViewGroup.MarginLayoutParams) fab.getLayoutParams();
            lpFab.bottomMargin += insets.getSystemWindowInsetBottom(); // portrait
            lpFab.rightMargin += insets.getSystemWindowInsetRight(); // landscape
            fab.setLayoutParams(lpFab);

            // we place a background behind the status bar to combine with it's semi-transparent
            // color to get the desired appearance.  Set it's height to the status bar height
            View statusBarBackground = findViewById(R.id.status_bar_background);
            FrameLayout.LayoutParams lpStatus = (FrameLayout.LayoutParams) statusBarBackground
                    .getLayoutParams();
            lpStatus.height = insets.getSystemWindowInsetTop();
            statusBarBackground.setLayoutParams(lpStatus);

            // clear this listener so insets aren't re-applied
            drawer.setOnApplyWindowInsetsListener(null);

            return insets.consumeSystemWindowInsets();
        }
    });
    setupTaskDescription();

    dataManager.loadFromDatabase();

    checkEmptyState();
    checkConnectivity();
}

From source file:com.commit451.springy.CompanionWatchFaceConfigActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().getDecorView()//  w w  w  .  java 2  s  .  c om
            .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
    setContentView(R.layout.config_activity);

    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    // Set up general chrome
    ImageButton doneButton = (ImageButton) findViewById(R.id.done_button);
    doneButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });

    ScrimInsetsFrameLayout scrimInsetsFrameLayout = (ScrimInsetsFrameLayout) findViewById(
            R.id.scrim_insets_frame_layout);
    scrimInsetsFrameLayout.setOnInsetsCallback(new ScrimInsetsFrameLayout.OnInsetsCallback() {
        @Override
        public void onInsetsChanged(Rect insets) {
            findViewById(R.id.chrome_container).setPadding(0, insets.top, 0, 0);
        }
    });

    // Set up theme list
    mMainClockContainerView = (ViewGroup) ((ViewGroup) findViewById(R.id.clock_container)).getChildAt(0);
    mMainClockView = (SpringyNumberView) mMainClockContainerView.findViewById(R.id.clock);

    mAnimateClockContainerView = (ViewGroup) ((ViewGroup) findViewById(R.id.clock_container)).getChildAt(1);
    mAnimateClockView = (SpringyNumberView) mAnimateClockContainerView.findViewById(R.id.clock);

    mAnimateClockContainerView.setVisibility(View.INVISIBLE);

    setupThemeList();
    String themeId = mSharedPreferences.getString(ConfigHelper.KEY_THEME, Themes.DEFAULT_THEME.id);
    updateUIToSelectedTheme(themeId, false);

    registerSharedPrefsListener();

    // Set up complications config fragment
    mConfigComplicationsFragment = (ConfigComplicationsFragment) getFragmentManager()
            .findFragmentById(R.id.config_complications_container);
    if (mConfigComplicationsFragment == null) {
        mConfigComplicationsFragment = new ConfigComplicationsFragment();
        getFragmentManager().beginTransaction()
                .add(R.id.config_complications_container, mConfigComplicationsFragment).commit();
    }

    // Set up tabs/pager
    final ViewPager pager = (ViewPager) findViewById(R.id.view_pager);
    pager.setPageMargin((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16,
            getResources().getDisplayMetrics()));

    SimplePagerHelper helper = new SimplePagerHelper(this, pager);
    helper.addPage(R.string.title_theme, R.id.config_theme_container);
    helper.addPage(R.string.title_complications, R.id.config_complications_container);

    TabLayout slidingTabLayout = (TabLayout) findViewById(R.id.tabs);
    slidingTabLayout.setupWithViewPager(pager);

    pager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            super.onPageScrolled(position, positionOffset, positionOffsetPixels);
            float translationX = -pager.getWidth();
            if (position == 0) {
                translationX = -positionOffsetPixels;
            }
            mMainClockView.setTranslationX(translationX);
            mAnimateClockView.setTranslationX(translationX);
        }
    });

    mTime = new Time();
    mTimerHandler = new Handler();

    mTimeChecker.run();
}

From source file:org.secuso.privacyfriendlynetmonitor.Activities.TutorialActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Checking for first time launch - before calling setContentView()
    prefManager = new PrefManager(this);
    if (!prefManager.isFirstTimeLaunch()) {
        launchHomeScreen();//from w w w . j av  a  2 s  .  c  o m
        finish();
    }

    // Making notification bar transparent
    if (Build.VERSION.SDK_INT >= 21) {
        getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
    }

    setContentView(R.layout.activity_tutorial);

    viewPager = (ViewPager) findViewById(R.id.view_pager);
    dotsLayout = (LinearLayout) findViewById(R.id.layoutDots);
    btnSkip = (Button) findViewById(R.id.btn_skip);
    btnNext = (Button) findViewById(R.id.btn_next);

    // layouts of all welcome sliders
    // add few more layouts if you want
    layouts = new int[] { R.layout.tutorial_slide1, R.layout.tutorial_slide2, };

    // adding bottom dots
    addBottomDots(0);

    // making notification bar transparent
    changeStatusBarColor();

    myViewPagerAdapter = new MyViewPagerAdapter();
    viewPager.setAdapter(myViewPagerAdapter);
    viewPager.addOnPageChangeListener(viewPagerPageChangeListener);

    btnSkip.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            launchHomeScreen();
        }
    });

    btnNext.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // checking for last page
            // if last page home screen will be launched
            int current = getItem(+1);
            if (current < layouts.length) {
                // move to next screen
                viewPager.setCurrentItem(current);
            } else {
                launchHomeScreen();
            }
        }
    });
}

From source file:com.guodong.sun.guodong.activity.ZhiHuDetailActivity.java

@Override
protected void initViews(Bundle savedInstanceState) {

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        View decorView = getWindow().getDecorView();
        int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
        decorView.setSystemUiVisibility(option);
        getWindow().setStatusBarColor(Color.TRANSPARENT);
    }//  w w w. j  a  v  a  2  s. co m

    //        mToolbar.setNavigationIcon(R.drawable.ic_arrow_back);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    ViewCompat.setTransitionName(mImageView, TRANSIT_PIC);

    initWebView();
    initShare();

    //        mAlertDialog = new AlertDialog.Builder(this).create();
    //        mAlertDialog.setView(getLayoutInflater().inflate(R.layout.loading_layout, null));

    mZhihuDetailPresenter = new ZhihuDetailPresenterImpl(this, this.bindToLifecycle());
    mId = getIntent().getIntExtra(EXTRA_ID, 0);
    mZhihuDetailPresenter.getZhihuDetailData(mId);

    mFButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ShareBoardConfig config = new ShareBoardConfig();
            config.setMenuItemBackgroundShape(ShareBoardConfig.BG_SHAPE_NONE);
            mShareAction.open(config);
        }
    });
}

From source file:uk.ac.horizon.artcodes.scanner.ScannerActivity.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void hideSystemUI() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
    }//  w ww .  j a va2s.  c  o m
}

From source file:com.pimp.instincts.activities.GalleryActivity.java

@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    View decorView = getWindow().getDecorView();
    if (hasFocus) {
        decorView.setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
    }//w  ww .j  a  va 2s .co m
}