List of usage examples for android.view Window getDecorView
public abstract View getDecorView();
From source file:free.yhc.netmbuddy.utils.Utils.java
/** * Only available when status bar is showing. * @param activity/* www.j av a2 s . c o m*/ * @return */ public static int getStatusBarHeight(Activity activity) { Rect rect = new Rect(); Window window = activity.getWindow(); window.getDecorView().getWindowVisibleDisplayFrame(rect); // Below is for future reference. // int StatusBarHeight = rect.top; // int contentViewTop = window.findViewById(Window.ID_ANDROID_CONTENT).getTop(); // int TitleBarHeight= contentViewTop - StatusBarHeight; return rect.top; }
From source file:org.huxizhijian.sdk.util.StatusBarUtil.java
public static void setFullScreen(Activity activity) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = activity.getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); window.getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.TRANSPARENT); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // ???,? ContentView ? activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); }//from w w w . jav a 2s. co m }
From source file:com.apptentive.android.sdk.util.Util.java
public static int getStatusBarHeight(Window window) { Rect rectangle = new Rect(); window.getDecorView().getWindowVisibleDisplayFrame(rectangle); return rectangle.top; }
From source file:com.miz.utils.ViewUtils.java
public static void setupWindowFlagsForStatusbarOverlay(Window window, boolean setBackgroundResource) { if (MizLib.isKitKat()) { // If we're running on KitKat, we want to enable // the translucent status bar window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); }/*from w ww .j a va2s .c o m*/ if (MizLib.hasKitKat()) { // If we're running on KitKat or above, we want to show // the background image beneath the status bar as well. window.getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); } // Make the status bar color transparent to begin with if (MizLib.hasLollipop()) window.setStatusBarColor(Color.TRANSPARENT); // If requested, set a background resource on the Window object if (setBackgroundResource) window.setBackgroundDrawableResource(R.drawable.bg); }
From source file:org.pixmob.freemobile.netstat.ui.MobileNetworkChartActivity.java
@Override public void onAttachedToWindow() { super.onAttachedToWindow(); // Enable "better" gradients: // http://stackoverflow.com/a/2932030/422906 final Window window = getWindow(); window.setFormat(PixelFormat.RGBA_8888); window.getDecorView().getBackground().setDither(true); }
From source file:com.jun.elephant.ui.widget.VoteDialog.java
private void initContentView() { View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_vote, null); Rect displayRectangle = new Rect(); Window window = getWindow(); window.getDecorView().getWindowVisibleDisplayFrame(displayRectangle); view.setMinimumWidth((int) (displayRectangle.width() * 0.8f)); window.setBackgroundDrawableResource(R.color.dialog_bg); setContentView(view);//from ww w .j a va 2s . c o m }
From source file:dg.shenm233.mmaps.ui.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Window window = getWindow(); window.getDecorView() .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(getResources().getColor(R.color.status_bar_color)); setContentView(R.layout.activity_main); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); initNavigationView();//from w w w .j ava2 s .c om FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.id.main_content, getMapsFragment(), MapsFragment.class.getName()); ft.commit(); }
From source file:org.liberty.android.fantastischmemo.downloader.google.GoogleOAuth2AccessCodeRetrievalFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreate(savedInstanceState); final View v = inflater.inflate(R.layout.oauth_login_layout, container, false); final WebView webview = (WebView) v.findViewById(R.id.login_page); final View loadingText = v.findViewById(R.id.auth_page_load_text); final View progressDialog = v.findViewById(R.id.auth_page_load_progress); final LinearLayout ll = (LinearLayout) v.findViewById(R.id.ll); // We have to set up the dialog's webview size manually or the webview will be zero size. // This should be a bug of Android. Rect displayRectangle = new Rect(); Window window = mActivity.getWindow(); window.getDecorView().getWindowVisibleDisplayFrame(displayRectangle); ll.setMinimumWidth((int) (displayRectangle.width() * 0.9f)); ll.setMinimumHeight((int) (displayRectangle.height() * 0.8f)); webview.getSettings().setJavaScriptEnabled(true); try {/*from ww w . j a va 2s . c om*/ String uri = String.format( "https://accounts.google.com/o/oauth2/auth?client_id=%s&response_type=%s&redirect_uri=%s&scope=%s", URLEncoder.encode(AMEnv.GOOGLE_CLIENT_ID, "UTF-8"), URLEncoder.encode("code", "UTF-8"), URLEncoder.encode(AMEnv.GOOGLE_REDIRECT_URI, "UTF-8"), URLEncoder.encode(AMEnv.GDRIVE_SCOPE, "UTF-8")); webview.loadUrl(uri); } catch (Exception e) { throw new RuntimeException(e); } // This is workaround to show input on some android version. webview.requestFocus(View.FOCUS_DOWN); webview.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_UP: if (!v.hasFocus()) { v.requestFocus(); } break; } return false; } }); webview.setWebViewClient(new WebViewClient() { private boolean authenticated = false; @Override public void onPageFinished(WebView view, String url) { loadingText.setVisibility(View.GONE); progressDialog.setVisibility(View.GONE); webview.setVisibility(View.VISIBLE); if (authenticated == true) { return; } String code = getAuthCodeFromUrl(url); String error = getErrorFromUrl(url); if (error != null) { authCodeReceiveListener.onAuthCodeError(error); authenticated = true; dismiss(); } if (code != null) { authenticated = true; authCodeReceiveListener.onAuthCodeReceived(code); dismiss(); } } }); return v; }
From source file:com.bottomsheetbehavior.ScrollingAppBarLayoutBehavior.java
private void setStatusBarBackgroundVisible(boolean visible) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && mStatusBarColor != 0) { if (visible) { Window window = ((ThemedReactContext) mContext).getCurrentActivity().getWindow(); window.getDecorView().setSystemUiVisibility(mBarStyle); window.setStatusBarColor(mStatusBarColor); } else {//from www .j a va 2s. c o m Window window = ((ThemedReactContext) mContext).getCurrentActivity().getWindow(); window.getDecorView().setSystemUiVisibility(mBarStyleTransparent); window.setStatusBarColor(ContextCompat.getColor(mContext, android.R.color.transparent)); } } }
From source file:com.experiments.whereapp.application.home.activities.HomeActivity.java
@TargetApi(Build.VERSION_CODES.KITKAT) @Override//w w w .jav a2 s . c o m public void makeStatusBarTransparent() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return; Window window = getWindow(); window.getDecorView() .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { window.setStatusBarColor(Color.TRANSPARENT); } else { window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } }