Java Code Examples for android.view.View.setSystemUiVisibility()

The following are Jave code examples for showing how to use setSystemUiVisibility() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: javaide   File: FullScreenActivity.java   Source Code and License Vote up 8 votes
private void enabledFullScreenMode() {
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    View decorView = getWindow().getDecorView();
    // Hide the status bar.
    int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
    decorView.setSystemUiVisibility(uiOptions);
}
 
Example 2
Project: GitHub   File: IjkPlayerView.java   Source Code and License Vote up 6 votes
/**
 * 设置UI沉浸式显示
 */
private void _setUiLayoutFullscreen() {
    if (Build.VERSION.SDK_INT >= 14) {
        // 获取关联 Activity 的 DecorView
        View decorView = mAttachActivity.getWindow().getDecorView();
        // 沉浸式使用这些Flag
        decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
                View.SYSTEM_UI_FLAG_FULLSCREEN |
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
                View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
                View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
                View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
        );
        mAttachActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }
}
 
Example 3
Project: Amazing   File: ConstraintActivity.java   Source Code and License Vote up 6 votes
private void fullscreen() {
    View decorView = getWindow().getDecorView();
    // Hide the status bar.
    int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
    decorView.setSystemUiVisibility(uiOptions);
    // Remember that you should never show the action bar if the
    // status bar is hidden, so hide that too if necessary.
    //        ActionBar actionBar = getActionBar();
    //        actionBar.hide();
}
 
Example 4
Project: androidnative.pri   File: Util.java   Source Code and License Vote up 6 votes
static void setFullScreen(Map message) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP ) { 
        return;
    }

    final Boolean value = (Boolean) message.get("value");
    final Activity activity = QtNative.activity();

    Runnable runnable = new Runnable () {
        public void run() {
            Window w = activity.getWindow(); // in Activity's onCreate() for instance
            View decorView = w.getDecorView();

            int config = decorView.getSystemUiVisibility();

            if (value) {
                config &= ~View.SYSTEM_UI_FLAG_FULLSCREEN;
            } else {
                config |= View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
            }
            decorView.setSystemUiVisibility(config);
        }
    };

    activity.runOnUiThread(runnable);

}
 
Example 5
Project: ApplicationCollention   File: TopbarActivity.java   Source Code and License Vote up 5 votes
/**
 * 设置状态栏颜色
 */
private void setStatusBar() {
    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(getResources().getColor(R.color.colorPrimary));
    }else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }
}
 
Example 6
Project: buildAPKsSamples   File: ContentFragment.java   Source Code and License Vote up 5 votes
/** Toggle whether the system UI (status bar / system bar) is visible.
 *  This also toggles the action bar visibility.
 * @param show True to show the system UI, false to hide it.
 */
void setSystemUiVisible(boolean show) {
    mSystemUiVisible = show;

    Window window = getActivity().getWindow();
    WindowManager.LayoutParams winParams = window.getAttributes();
    View view = getView();
    ActionBar actionBar = getActivity().getActionBar();

    if (show) {
        // Show status bar (remove fullscreen flag)
        window.setFlags(0, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        // Show system bar
        view.setSystemUiVisibility(View.STATUS_BAR_VISIBLE);
        // Show action bar
        actionBar.show();
    } else {
        // Add fullscreen flag (hide status bar)
        window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
        // Hide system bar
        view.setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
        // Hide action bar
        actionBar.hide();
    }
    window.setAttributes(winParams);
}
 
Example 7
Project: music-player   File: ViewUtils.java   Source Code and License Vote up 5 votes
public static void clearLightStatusBar(@NonNull View view) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        int flags = view.getSystemUiVisibility();
        flags &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        view.setSystemUiVisibility(flags);
    }
}
 
Example 8
Project: TravelJournal   File: BaseActivity.java   Source Code and License Vote up 5 votes
public static void setLightStatusBar(View view, Activity activity){
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {

        int flags = view.getSystemUiVisibility();
        flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        view.setSystemUiVisibility(flags);
        activity.getWindow().setStatusBarColor(Color.WHITE);
    }
}
 
Example 9
Project: AmenEye   File: ViewUtil.java   Source Code and License Vote up 5 votes
public static void clearLightStatusBar(@NonNull View view) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        int flags = view.getSystemUiVisibility();
        flags &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        view.setSystemUiVisibility(flags);
    }
}
 
Example 10
Project: memetastic   File: ContextUtils.java   Source Code and License Vote up 5 votes
public void enableImmersiveMode(final View decorViewOfActivity) {
    decorViewOfActivity.setSystemUiVisibility(getImmersiveUiVisibility());
    decorViewOfActivity.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
        @Override
        public void onSystemUiVisibilityChange(int visibility) {
            if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
                decorViewOfActivity.setSystemUiVisibility(getImmersiveUiVisibility());
            }
        }
    });
}
 
Example 11
Project: ShotsNewsApp   File: PptWebViewActivity.java   Source Code and License Vote up 5 votes
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        View decorView = getWindow().getDecorView();
// Hide the status bar.
        int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
        decorView.setSystemUiVisibility(uiOptions);
// Remember that you should never show the action bar if the
// status bar is hidden, so hide that too if necessary.
        //android.app.ActionBar actionBar = getActionBar();
        // actionBar.hide();
        setContentView(R.layout.activity_ppt_web_view);

//        mVisible = true;
//        mControlsView = findViewById(R.id.fullscreen_content_controls);
//        mContentView = findViewById(R.id.fullscreen_content);
//
//
//        // Set up the user interaction to manually show or hide the system UI.
//        mContentView.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                toggle();
//            }
//        });

        Intent intent=getIntent();
        String url=intent.getStringExtra("modulelink");
        url=url.replaceAll(" ","%20");
        webView = (WebView)findViewById(R.id.webView2);
        webView.getSettings().setJavaScriptEnabled(true);
        Uri uri = Uri.parse("https://www.example.com");
        //  webView.loadUrl("https://view.officeapps.live.com/op/view.aspx?src=http%3a%2f%2fvideo.ch9.ms%2fbuild%2f2011%2fslides%2fTOOL-532T_Sutter.pptx");
        // webView.loadUrl("https://view.officeapps.live.com/op/view.aspx?src=https://www.dropbox.com/s/2scazhwg7o5l2z3/SE1.pptx?dl=1");
        //   webView.loadUrl("https://view.officeapps.live.com/op/view.aspx?src=https://www.dropbox.com/s/n775vtevnwlqzlg/test.pptx?dl=1");


        webView.getSettings().setLoadsImagesAutomatically(true);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
        webView.setWebViewClient(new WebViewClient());
        webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
//        webView.loadUrl("https://view.officeapps.live.com/op/view.aspx?src=http%3a%2f%2fvideo.ch9.ms%2fbuild%2f2011%2fslides%2fTOOL-532T_Sutter.pptx");
        webView.loadUrl("https://view.officeapps.live.com/op/view.aspx?src="+url);


        // Upon interacting with UI controls, delay any scheduled hide()
        // operations to prevent the jarring behavior of controls going away
        // while interacting with the UI.
        // findViewById(R.id.dummy_button).setOnTouchListener(mDelayHideTouchListener);
    }
 
Example 12
Project: MyAnimeViewer   File: OfflineVideoDetailsFragment.java   Source Code and License Vote up 5 votes
private void hideLandscapeSystemUI() {
    final View decorView = getActivity().getWindow().getDecorView();

    // Set the IMMERSIVE flag.
    // Set the content to appear under the system bars so that the content
    // doesn't resize when the system bars hide and show.
    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 // hide nav bar
                    | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
                    | View.SYSTEM_UI_FLAG_IMMERSIVE);
}
 
Example 13
Project: NovelReader   File: SystemBarUtils.java   Source Code and License Vote up 5 votes
public static void clearFlag(Activity activity, int flag){
    if (Build.VERSION.SDK_INT >= 19){
        View decorView = activity.getWindow().getDecorView();
        int option = decorView.getSystemUiVisibility() & (~flag);
        decorView.setSystemUiVisibility(option);
    }
}
 
Example 14
Project: Ariana   File: Utils.java   Source Code and License Vote up 5 votes
public static void hideStatusbar(Activity context) {
    if (Build.VERSION.SDK_INT < 16) {
        context.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    } else {
        View decorView = context.getWindow().getDecorView();
        int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
        decorView.setSystemUiVisibility(uiOptions);
    }
}
 
Example 15
Project: CommonsLab   File: SplashScreenActivity.java   Source Code and License Vote up 5 votes
private void hideStatusBar() {
    // If the Android version is lower than Jellybean, use this call to hide
    // the status bar.
    if (Build.VERSION.SDK_INT < 16) {
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }

    //Hide the Status Bar on Android 4.1 and Higher
    View decorView = getWindow().getDecorView();
    // Hide the status bar.
    int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
    decorView.setSystemUiVisibility(uiOptions);
}
 
Example 16
Project: MyAnimeViewer   File: VideoPlayerActivity.java   Source Code and License Vote up 5 votes
private void showLandscapeSystemUI() {
    final 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);

}
 
Example 17
Project: myCoolWeather   File: WeatherActivity.java   Source Code and License Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if(Build.VERSION.SDK_INT >= 21){
        View decorView = getWindow().getDecorView();
        decorView.setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE
        );
        getWindow().setStatusBarColor(Color.TRANSPARENT);
    }

    setContentView(R.layout.activity_weather);

    initView();



    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    String weatherString =prefs.getString("weather",null);

    String bingPic =prefs.getString("bing_pic",null);

    if(bingPic != null){
        Glide.with(this).load(bingPic).into(bingPicImg);
    }else {
        loadBingPic();
    }

    if(weatherString != null){
        //有缓存时直接解析天气数据
        Weather weather = Utility.handleWeatherResponse(weatherString);
        mWeatherId = weather.basic.weatherId;
        showWeatherInfo(weather);
    }else {
        //无缓存时去服务器查询天气
         mWeatherId = getIntent().getStringExtra("weather_id");
        weatherLayout.setVisibility(View.INVISIBLE);
        requestWeather(mWeatherId);
    }


    swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            requestWeather(mWeatherId);
        }
    });


    navButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            drawerLayout.openDrawer(GravityCompat.START);
        }
    });
}
 
Example 18
Project: Shared-Route   File: PayBillActivity.java   Source Code and License Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_pay_bill);
    View decorView = getWindow().getDecorView();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
        decorView.setSystemUiVisibility(option);
        getWindow().setStatusBarColor(Color.TRANSPARENT);
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        Window window = getWindow();
        // Translucent status bar
        window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager
                .LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }
    Intent intent = getIntent();
    final Bundle bundle = intent.getExtras();

    vertifyView=(TextView)findViewById(R.id.timer);
    final TextView money = (TextView)findViewById(R.id.textView3);
    TextView name=(TextView)findViewById(R.id.textView4);
    TextView phone = (TextView)findViewById(R.id.textView7);
    TextView packSort= (TextView)findViewById(R.id.textView8);
    TextView pickNum = (TextView)findViewById(R.id.textView9);
    Button pickPlace=(Button)findViewById(R.id.button);
    Button delieverPlace = (Button)findViewById(R.id.button2);
    TextView pickTime =(TextView)findViewById(R.id.pick_time);
    TextView delieverTime=(TextView)findViewById(R.id.deliever_time);
    Button ensureBillBtn = (Button)findViewById(R.id.ensure_bill_btn);

    Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
    toolbar.setTitle("确认支付");
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if(actionBar != null){
        actionBar.setDisplayHomeAsUpEnabled(true);
    }


    timer.start();
    EditText total = (EditText)findViewById(R.id.textView3);

    total.setKeyListener(null);

    String fetchTime = bundle.getString("pickuptime");
    int index1 = fetchTime.indexOf('日');
    fetchTime = "\t\t\t\t"+fetchTime.substring(0,index1+1)+" "+fetchTime.substring(index1+2);
    String sendTime = bundle.getString("delievertime");
    int index2 = sendTime.indexOf('日');
    sendTime = "\t\t\t\t"+sendTime.substring(0,index2+1)+" "+sendTime.substring(index2+2);

    if(bundle!=null){
        money.setText("¥ "+bundle.getString("money"));
        name.setText(bundle.getString("name"));
        phone.setText(bundle.getString("phone"));
        packSort.setText(bundle.getString("packsort"));
        pickNum.setText(bundle.getString("num"));
        pickPlace.setText(bundle.getString("pickupplace"));
        delieverPlace.setText(bundle.getString("delieverplace"));
        pickTime.setText(fetchTime);
        delieverTime.setText(sendTime);
        ensureBillBtn.setText("确认支付 ¥ "+bundle.getString("money"));
    }


    mPostInfoFormView = findViewById(R.id.pay_form);
    mProgressView = findViewById(R.id.pay_progress);

    ensureBillBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            SharedPreferences sp = getSharedPreferences("now_account", Context.MODE_PRIVATE);
            String stuNum = sp.getString("now_stu_num", null);
            FetchUserInfo fetchUserInfo = new FetchUserInfo(stuNum);
            fetchUserInfo.execute();

        }
    });
}
 
Example 19
Project: coolWeather   File: WeatherAcitivity.java   Source Code and License Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (Build.VERSION.SDK_INT >= 21) {
        View decorView = getWindow().getDecorView();
        decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        getWindow().setStatusBarColor(Color.TRANSPARENT);
    }

    setContentView(R.layout.activity_weather);
    weatherLayout = (ScrollView) findViewById(R.id.weather_layout);
    titleCity = (TextView) findViewById(R.id.title_city);
    titleUpdateTime = (TextView) findViewById(R.id.title_ypdate_time);
    degreeText = (TextView)findViewById(R.id.degree_text);
    weatherInfoText = (TextView) findViewById(R.id.weather_info_text);
    forecastLayout = (LinearLayout) findViewById(R.id.forecast_layout);
    aqiText = (TextView) findViewById(R.id.aqi_text);
    pm25Text = (TextView) findViewById(R.id.pm25_text);
    comfortText = (TextView) findViewById(R.id.comfort_text);
    carWashText = (TextView) findViewById(R.id.car_wash_text);
    sportText = (TextView) findViewById(R.id.sport_text);
    bingPicImage = (ImageView) findViewById(R.id.bing_pic_img);

    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh);
    swipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary);

    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    navButton = (Button) findViewById(R.id.nav_button);
    navButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            drawerLayout.openDrawer(GravityCompat.START);
        }
    });

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    String weatherString = preferences.getString("weather", null);
    if (weatherString != null) {
        Weather weather = Utility.handleWeatherResponse(weatherString);
        mWeatherId = weather.basic.weatherId;
        showWeatherInfo(weather);
    } else {
        mWeatherId = getIntent().getStringExtra("weather_id");
        weatherLayout.setVisibility(View.INVISIBLE);
        requestWeather(mWeatherId);
    }
    String bingPic = preferences.getString("bing_pic", null);
    if (bingPic != null) {
        Glide.with(this).load(bingPic).into(bingPicImage);
    } else {
        loadBingPic();
    }

    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            requestWeather(mWeatherId);
        }
    });
}
 
Example 20
Project: BilibiliClient   File: SystemUiVisibilityUtil.java   Source Code and License Vote up 2 votes
public static void clearFlags(View view, int flags) {

    view.setSystemUiVisibility(view.getSystemUiVisibility() & ~flags);
  }