Java Code Examples for android.view.Window

The following examples show how to use android.view.Window. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: ShoppingList   Source File: CustomDialogShoppingListOptions.java    License: MIT License 6 votes vote down vote up
public CustomDialogShoppingListOptions(Context context, int idShoppingList) {
    super(context);

    setCancelable(true);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    String[] options = { context.getString(R.string.rename), context.getString(R.string.duplicate), context.getString(R.string.delete), context.getString(R.string.schedule), context.getString(R.string.share), context.getString(R.string.share_via_text) };

    OptionAdapter adapter = new OptionAdapter(context, options);
    ListView lv = new ListView(context);

    lv.setAdapter(adapter);
    lv.setLayoutParams(new ListView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    lv.setOnItemClickListener(this);

    this.context = context;
    this.idShoppingList = idShoppingList;
    setContentView(lv);
}
 
Example 2
/**
 * 初始化窗口
 *
 * @param window
 */
protected void initWindows(Window window) {

    if (this.mAnim != CLOSE) {

        if (this.mAnim == NONE) { // 默认动画
            if (BitManager.getInstance().getDialogAnim() != NONE) {
                window.getAttributes().windowAnimations =
                        BitManager.getInstance().getDialogAnim();
            }
        } else {    // 自行设置动画
            window.getAttributes().windowAnimations = this.mAnim;
        }
    }

}
 
Example 3
Source Project: Clip-Stack   Source File: MyActionBarActivity.java    License: MIT License 6 votes vote down vote up
@Override
public void onGlobalLayout() {
    int heightDiff = rootLayout.getRootView().getHeight() - rootLayout.getHeight();
    int contentViewTop = getWindow().findViewById(Window.ID_ANDROID_CONTENT).getHeight();

    if (heightDiff <= contentViewTop) {
        if (!isKeyboardShow) return;
        onHideKeyboard();
        isKeyboardShow = false;

    } else {
        if (isKeyboardShow) return;
        int keyboardHeight = heightDiff - contentViewTop;
        onShowKeyboard(keyboardHeight);
        isKeyboardShow = true;

    }
}
 
Example 4
Source Project: AndroidUtilCode   Source File: KeyboardUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Register soft input changed listener.
 *
 * @param window   The window.
 * @param listener The soft input changed listener.
 */
public static void registerSoftInputChangedListener(@NonNull final Window window,
                                                    @NonNull final OnSoftInputChangedListener listener) {
    final int flags = window.getAttributes().flags;
    if ((flags & WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS) != 0) {
        window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    }
    final FrameLayout contentView = window.findViewById(android.R.id.content);
    final int[] decorViewInvisibleHeightPre = {getDecorViewInvisibleHeight(window)};
    OnGlobalLayoutListener onGlobalLayoutListener = new OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            int height = getDecorViewInvisibleHeight(window);
            if (decorViewInvisibleHeightPre[0] != height) {
                listener.onSoftInputChanged(height);
                decorViewInvisibleHeightPre[0] = height;
            }
        }
    };
    contentView.getViewTreeObserver().addOnGlobalLayoutListener(onGlobalLayoutListener);
    contentView.setTag(TAG_ON_GLOBAL_LAYOUT_LISTENER, onGlobalLayoutListener);
}
 
Example 5
@Override
public void setContentView(View view, ViewGroup.LayoutParams params) {
    if (ActionBarSherlock.DEBUG) Log.d(TAG, "[setContentView] view: " + view + ", params: " + params);

    if (mContentParent == null) {
        installDecor();
    } else {
        mContentParent.removeAllViews();
    }
    mContentParent.addView(view, params);

    Window.Callback callback = mActivity.getWindow().getCallback();
    if (callback != null) {
        callback.onContentChanged();
    }

    initActionBar();
}
 
Example 6
Source Project: android_9.0.0_r45   Source File: ActivityTransitionState.java    License: Apache License 2.0 6 votes vote down vote up
public void setEnterActivityOptions(Activity activity, ActivityOptions options) {
    final Window window = activity.getWindow();
    if (window == null) {
        return;
    }
    // ensure Decor View has been created so that the window features are activated
    window.getDecorView();
    if (window.hasFeature(Window.FEATURE_ACTIVITY_TRANSITIONS)
            && options != null && mEnterActivityOptions == null
            && mEnterTransitionCoordinator == null
            && options.getAnimationType() == ActivityOptions.ANIM_SCENE_TRANSITION) {
        mEnterActivityOptions = options;
        mIsEnterTriggered = false;
        if (mEnterActivityOptions.isReturning()) {
            restoreExitedViews();
            int result = mEnterActivityOptions.getResultCode();
            if (result != 0) {
                Intent intent = mEnterActivityOptions.getResultData();
                if (intent != null) {
                    intent.setExtrasClassLoader(activity.getClassLoader());
                }
                activity.onActivityReenter(result, intent);
            }
        }
    }
}
 
Example 7
Source Project: timecat   Source File: EmotionKeyboard.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 释放被锁定的内容高度
 */
private void unlockContentHeightDelayed() {
    mEditText.postDelayed(new Runnable() {
        @Override
        public void run() {
            mActivity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN |
                    WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
            //窗口对齐屏幕宽度
            Window win = mActivity.getWindow();
            win.getDecorView().setPadding(0, 0, 0, 0);
            WindowManager.LayoutParams lp = win.getAttributes();
            lp.gravity = Gravity.BOTTOM;//设置对话框置顶显示
            lp.y = 0;
            win.setAttributes(lp);
        }
    }, 300);
}
 
Example 8
Source Project: LoveTalkClient   Source File: LoginActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	setContentView(R.layout.activity_login);

	enterLogin = (EditText) findViewById(R.id.enterlogin);
	enterPassword = (EditText) findViewById(R.id.enterpassword);
	registebtn = (ImageView) findViewById(R.id.registebtn);
	loginbtn = (ImageView) findViewById(R.id.loginbtn);
	forgetbtn = (ImageView) findViewById(R.id.forget);

	enterLogin.setOnFocusChangeListener(this);
	enterPassword.setOnFocusChangeListener(this);
	registebtn.setOnClickListener(this);
	loginbtn.setOnClickListener(this);
	forgetbtn.setOnClickListener(this);
}
 
Example 9
Source Project: XERUNG   Source File: Logout.java    License: Apache License 2.0 6 votes vote down vote up
public Logout(Context context, String emailID, Object dashBoardActivity) {
	super(context);
	// TODO Auto-generated constructor stub
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	setContentView(R.layout.dialog_logout);
	getWindow().setBackgroundDrawable(new ColorDrawable(android.R.color.transparent));
	setCancelable(false);
	this.context = context;
	roboto = Typeface.createFromAsset(context.getAssets(),"font/Roboto-Regular.ttf");
	activity = (Activity) context;
	pbbar = new ProgressDialog();
	db = new GroupDb(context);
	this.email= emailID;
	dashBoardActObjecct = dashBoardActivity;
	
}
 
Example 10
Source Project: UltimateAndroid   Source File: QuickContactFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    if (getDialog() != null) {
        getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
        getDialog().getWindow().setBackgroundDrawableResource(android.R.color.transparent);
    }

    View root = inflater.inflate(R.layout.viewpager_sliding_tabs_fragment_quick_contact, container, false);

    tabs = (PagerSlidingTabStrip) root.findViewById(R.id.tabs);
    pager = (ViewPager) root.findViewById(R.id.pager);
    adapter = new ContactPagerAdapter();

    pager.setAdapter(adapter);

    tabs.setViewPager(pager);

    return root;
}
 
Example 11
Source Project: DMusic   Source File: BaseFragmentActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContext = this;
    mActivity = this;
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(getLayoutRes());
    if (getDSLayoutRes() != 0) {
        mDslDs = (DSLayout) findViewById(getDSLayoutRes());
    }
    bindView();
    mUnbinder = ButterKnife.bind(this);
    mPresenter = getPresenter();
    if (mPresenter != null) {
        mPresenter.attachView(getMvpView());
    }
    init();
}
 
Example 12
Source Project: ColorPickerDialog   Source File: PickerDialog.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onResume() {
    super.onResume();

    Window window = getDialog().getWindow();
    DisplayMetrics displayMetrics = new DisplayMetrics();
    WindowManager windowmanager = window.getWindowManager();
    windowmanager.getDefaultDisplay().getMetrics(displayMetrics);

    window.setLayout(
            Math.min(DimenUtils.dpToPx(displayMetrics.widthPixels > displayMetrics.heightPixels ? 800 : 500),
                    (int) (displayMetrics.widthPixels * 0.9f)),
            WindowManager.LayoutParams.WRAP_CONTENT
    );

    GradientDrawable drawable = new GradientDrawable();
    drawable.setColor(ColorUtils.fromAttr(new ContextThemeWrapper(getContext(), getTheme()),
            android.R.attr.colorBackground, Color.WHITE));
    drawable.setCornerRadius(cornerRadius);

    window.setBackgroundDrawable(new InsetDrawable(drawable, DimenUtils.dpToPx(12)));
}
 
Example 13
Source Project: financisto   Source File: MainActivity.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    greenRobotBus = GreenRobotBus_.getInstance_(this);

    requestWindowFeature(Window.FEATURE_NO_TITLE);

    initialLoad();

    final TabHost tabHost = getTabHost();

    setupAccountsTab(tabHost);
    setupBlotterTab(tabHost);
    setupBudgetsTab(tabHost);
    setupReportsTab(tabHost);
    setupMenuTab(tabHost);

    MyPreferences.StartupScreen screen = MyPreferences.getStartupScreen(this);
    tabHost.setCurrentTabByTag(screen.tag);
    tabHost.setOnTabChangedListener(this);
}
 
Example 14
Source Project: guideshow   Source File: DialogFragment.java    License: MIT License 6 votes vote down vote up
/** @hide */
@Override
public LayoutInflater getLayoutInflater(Bundle savedInstanceState) {
    if (!mShowsDialog) {
        return super.getLayoutInflater(savedInstanceState);
    }

    mDialog = onCreateDialog(savedInstanceState);
    switch (mStyle) {
        case STYLE_NO_INPUT:
            mDialog.getWindow().addFlags(
                    WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
                    WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
            // fall through...
        case STYLE_NO_FRAME:
        case STYLE_NO_TITLE:
            mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    }
    if (mDialog != null) {
        return (LayoutInflater) mDialog.getContext().getSystemService(
                Context.LAYOUT_INFLATER_SERVICE);
    }
    return (LayoutInflater) mActivity.getSystemService(
            Context.LAYOUT_INFLATER_SERVICE);
}
 
Example 15
Source Project: StatusBarUtil   Source File: StatusBarUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 设置Flyme4+的状态栏的darkMode,darkMode时候字体颜色及icon
 * http://open-wiki.flyme.cn/index.php?title=Flyme%E7%B3%BB%E7%BB%9FAPI
 *
 * @param window 目标window
 * @param dark   亮色 or 暗色
 */
private static void setModeForFlyme4(Window window, boolean dark) {
    try {
        WindowManager.LayoutParams lp = window.getAttributes();
        Field darkFlag = WindowManager.LayoutParams.class.getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON");
        Field meizuFlags = WindowManager.LayoutParams.class.getDeclaredField("meizuFlags");
        darkFlag.setAccessible(true);
        meizuFlags.setAccessible(true);
        int bit = darkFlag.getInt(null);
        int value = meizuFlags.getInt(lp);
        if (dark) {
            value |= bit;
        } else {
            value &= ~bit;
        }
        meizuFlags.setInt(lp, value);
        window.setAttributes(lp);
    } catch (Exception e) {
        Log.e("StatusBar", "darkIcon: failed");
    }
}
 
Example 16
Source Project: scene   Source File: SwipeBackAppCompatScene.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    this.mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getNavigationScene().pop();
        }
    });
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Activity activity = this.requireActivity();
        Window window = activity.getWindow();
        window.setStatusBarColor(Color.TRANSPARENT);
        window.setNavigationBarColor(Color.TRANSPARENT);
    }
}
 
Example 17
Source Project: MultiScrollDemo   Source File: StatusBarUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 设置MIUI6+的状态栏是否为darkMode,darkMode时候字体颜色及icon变黑
 * http://dev.xiaomi.com/doc/p=4769/
 */
public static boolean darkModeForMIUI6(Window window, boolean darkmode) {
    Class<? extends Window> clazz = window.getClass();
    try {
        int darkModeFlag = 0;
        Class<?> layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");
        Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
        darkModeFlag = field.getInt(layoutParams);
        Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
        extraFlagField.invoke(window, darkmode ? darkModeFlag : 0, darkModeFlag);
        return true;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}
 
Example 18
Source Project: FimiX8-RE   Source File: StatusBarUtil.java    License: MIT License 6 votes vote down vote up
public static boolean FlymeSetStatusBarLightMode(Window window, boolean dark) {
    if (window == null) {
        return false;
    }
    try {
        WindowManager.LayoutParams lp = window.getAttributes();
        Field darkFlag = WindowManager.LayoutParams.class.getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON");
        Field meizuFlags = WindowManager.LayoutParams.class.getDeclaredField("meizuFlags");
        darkFlag.setAccessible(true);
        meizuFlags.setAccessible(true);
        int bit = darkFlag.getInt(null);
        int value = meizuFlags.getInt(lp);
        if (dark) {
            value |= bit;
        } else {
            value &= bit ^ -1;
        }
        meizuFlags.setInt(lp, value);
        window.setAttributes(lp);
        return true;
    } catch (Exception e) {
        return false;
    }
}
 
Example 19
Source Project: RxTools-master   Source File: RxBarTool.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 设置状态栏字体图标为深色,需要MIUIV6以上
 *
 * @param window 需要设置的窗口
 * @param dark   是否把状态栏字体及图标颜色设置为深色
 * @return boolean 成功执行返回true
 */
public static boolean MIUISetStatusBarLightMode(Window window, boolean dark) {
    boolean result = false;
    if (window != null) {
        Class clazz = window.getClass();
        try {
            int darkModeFlag = 0;
            Class layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");
            Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
            darkModeFlag = field.getInt(layoutParams);
            Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
            if (dark) {
                extraFlagField.invoke(window, darkModeFlag, darkModeFlag);//状态栏透明且黑色字体
            } else {
                extraFlagField.invoke(window, 0, darkModeFlag);//清除黑色字体
            }
            result = true;
        } catch (Exception e) {

        }
    }
    return result;
}
 
Example 20
Source Project: Dainty   Source File: ConfigActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    overridePendingTransition(R.anim.left_in, 0);
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = 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);
    }
    mSwipeBackLayout = new SwipeBackLayout(this);
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    ft.add(android.R.id.content, new SettingsFragment());
    ft.commit();
    PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);
}
 
Example 21
Source Project: XERUNG   Source File: RequestSendtoAdmin.java    License: Apache License 2.0 6 votes vote down vote up
public RequestSendtoAdmin(Context context, int id, String number,String name, String request, Object dashBoardActivity) {
	super(context);
	// TODO Auto-generated constructor stub
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	setContentView(R.layout.dialog_send_request_admin);
	getWindow().setBackgroundDrawable(new ColorDrawable(android.R.color.transparent));
	setCancelable(false);
	this.context = context;
	roboto = Typeface.createFromAsset(context.getAssets(),"font/Roboto-Regular.ttf");
	activity = (Activity) context;
	this.requestSend= request;
	this.groupName= name;
	this.groupNumber= number;
	this.gUID= id;
	dashBoardActObjecct = dashBoardActivity;
	shared = new SharedPreferanceData(context);
	requestDilog = this;
	comman = new Comman();
	
}
 
Example 22
Source Project: FloatingView   Source File: Floating.java    License: Apache License 2.0 6 votes vote down vote up
public Floating(Activity activity){

        if (activity == null){
            throw new NullPointerException("Activity should not be null");
        }
        
        ViewGroup rootView = (ViewGroup) activity.findViewById(Window.ID_ANDROID_CONTENT);
        View decorView = rootView.findViewById(R.id.floating_decor);
        if (decorView instanceof  FloatingDecorView){
            mFloatingDecorView = (FloatingDecorView) decorView;
        }else {
            mFloatingDecorView = new FloatingDecorView(activity);
            mFloatingDecorView.setId(R.id.floating_decor);
            rootView.addView(mFloatingDecorView);
        }
        
        if (mSpringSystem == null){
            mSpringSystem = SpringSystem.create();
        }
        
    }
 
Example 23
Source Project: palmsuda   Source File: Splash.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	// 设置为无标题栏
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	// 设置为全屏模式
	getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
			WindowManager.LayoutParams.FLAG_FULLSCREEN);
	setContentView(R.layout.splash);

	// 获取当前版本,并设置在启动界面的TextView
	this.getCurrentVersion();

	cover_page = (RelativeLayout) findViewById(R.id.cover_page);
	AlphaAnimation aa = new AlphaAnimation(0.1f, 1.0f);
	aa.setDuration(5000);
	cover_page.startAnimation(aa);

	Animation anim = android.view.animation.AnimationUtils.loadAnimation(
			this, R.anim.rotate);
	android.view.animation.LinearInterpolator lir = new android.view.animation.LinearInterpolator();
	anim.setInterpolator(lir);
	findViewById(R.id.progressBar1).startAnimation(anim);

	handler.postDelayed(new SplashHandler(), 8000);
	// 延迟8秒,再运行SplashHandler的run()方法
}
 
Example 24
Source Project: SmartRefreshHorizontal   Source File: StatusBarUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static void darkOnly(Activity activity) {
    Window window = activity.getWindow();
    if (isFlyme4Later()) {
        darkModeForFlyme4(window, true);
    } else if (isMIUI6Later()) {
        darkModeForMIUI6(window, true);
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        darkModeForM(window, true);
    }
}
 
Example 25
Source Project: okhttp-OkGo   Source File: BitmapDialogCallback.java    License: Apache License 2.0 5 votes vote down vote up
public BitmapDialogCallback(Activity activity) {
    super(1000, 1000);
    dialog = new ProgressDialog(activity);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    dialog.setMessage("请求网络中...");
}
 
Example 26
Source Project: BaseProject   Source File: BaseDialogFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

    mView = inflater.inflate(getLayoutId(), null);

    getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE); //去除标题栏

    /*// 设置宽度为屏宽、居中。
    Window window = getDialog().getWindow();
    WindowManager.LayoutParams params = window.getAttributes();
    params.gravity = Gravity.CENTER;*/

    return mView;
}
 
Example 27
Source Project: GPT   Source File: GPTInstrumentation.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 替换WindowCallback
 *
 * @param activity Activity
 */
public static void replaceWindowCallback(Activity activity) {
    activity.getWindow().setCallback(activity);

    Window.Callback callback = activity.getWindow().getCallback();

    WindowCallbackWorker callbackWorker = new WindowCallbackWorker();
    callbackWorker.mTarget = callback;
    callbackWorker.mActivity = activity;

    activity.getWindow().setCallback(callbackWorker);
}
 
Example 28
Source Project: BaseProject   Source File: BaseDialogFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onStart() {
    super.onStart();
    Dialog dialog = getDialog();
    Window window = dialog == null ? null : dialog.getWindow();
    if (null != dialog && null != window) {
        window.setLayout(-1, -2);
    }
}
 
Example 29
Source Project: delion   Source File: ChromeActivity.java    License: Apache License 2.0 5 votes vote down vote up
private int windowArea() {
    Window window = getWindow();
    if (window != null) {
        View view =  window.getDecorView();
        return view.getWidth() * view.getHeight();
    }
    return -1;
}
 
Example 30
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    instance = this;
    Window window = getWindow();
    window.setGravity(Gravity.LEFT | Gravity.TOP);
    WindowManager.LayoutParams params = window.getAttributes();
    params.x = 0;
    params.y = 0;
    params.height = 1;
    params.width = 1;
    window.setAttributes(params);
}