Window getAttributes - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Window getAttributes method.

This code example shows how to use the following methods:addFlags, getAttributes, setAttributes
 
        dialog.setCancelable(true);
        dialog.setCanceledOnTouchOutside(true);
 
        final Window window = dialog.getWindow();
        final WindowManager.LayoutParams lp = window.getAttributes();
        lp.token = windowToken;
        lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
        window.setAttributes(lp);
        window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
 
        mOptionsDialog = dialog;
        dialog.show();
    } 
 
    @Override 
    public void onCreate() { 
        super.onCreate(); 
        mImm = InputMethodManagerCompatWrapper.getInstance();
    } 
7
CodeRank
This code example shows how to use the following methods:getAttributes, setAttributes
        updateValueText(); 
    } 
 
    private void updateBrightness() { 
        if (mWindow != null) {
            LayoutParams params = mWindow.getAttributes();
            params.buttonBrightness = (float) mSeekBar.getProgress() / 100;
            mWindow.setAttributes(params);
        } 
    } 
 
    private void updateValueText() { 
        if (mValueText != null) {
            String text = String.valueOf(mSeekBar.getProgress()) + "%";
            mValueText.setText(text);
        } 
    } 
 
    @Override 
    public void onStartTrackingTouch(SeekBar seek) {
6
CodeRank
This code example shows how to use the following methods:addFlags, getAttributes, setAttributes
 
        dialog.setCancelable(true);
        dialog.setCanceledOnTouchOutside(true);
 
        final Window window = dialog.getWindow();
        final WindowManager.LayoutParams lp = window.getAttributes();
        lp.token = windowToken;
        lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
        window.setAttributes(lp);
        window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
 
        mOptionsDialog = dialog;
        dialog.show();
    } 
 
    @Override 
    public void onCreate() { 
        super.onCreate(); 
        mImm = InputMethodManagerCompatWrapper.getInstance();
    } 
7
CodeRank
This code example shows how to use the following methods:getAttributes, setAttributes
        updateValueText(); 
    } 
 
    private void updateBrightness() { 
        if (mWindow != null) {
            LayoutParams params = mWindow.getAttributes();
            params.buttonBrightness = (float) mSeekBar.getProgress() / 100;
            mWindow.setAttributes(params);
        } 
    } 
 
    private void updateValueText() { 
        if (mValueText != null) {
            String text = String.valueOf(mSeekBar.getProgress()) + "%";
            mValueText.setText(text);
        } 
    } 
 
    @Override 
    public void onStartTrackingTouch(SeekBar seek) {
6
CodeRank
This code example shows how to use the following methods:getAttributes, setAttributes
    } 
 
    private void setWindowBrightness( final Activity activity , final float value ) {
        final Window w = activity.getWindow();
 
        final WindowManager.LayoutParams lp = w.getAttributes();
        lp.screenBrightness = value;
        w.setAttributes( lp );
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getAttributes, setAttributes
    @Override 
	protected void onCreate(final Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
 
		final Window win = getWindow();
		final WindowManager.LayoutParams winParams = win.getAttributes();
		winParams.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
				| WindowManager.LayoutParams.FLAG_FULLSCREEN;
 
		// set screen brightness to the lowest possible without turning screen 
		// off 
		winParams.screenBrightness = 0.01f;
 
		// NOTE: this doesn't work on some devices (Motorola Droid, X, 2.. etc) 
		if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) {
			// hack for pre-froyo to set buttonBrightness off 
			try { 
				final Field buttonBrightness = winParams.getClass().getField("buttonBrightness");
				buttonBrightness.set(winParams, WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_OFF);
			} catch (final Exception e) {

6
CodeRank
This code example shows how to use the following methods:getAttributes, setAttributes
        int mode = Settings.System.getInt(
        		this.getContext().getContentResolver(),
                Settings.System.SCREEN_BRIGHTNESS_MODE,
                Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
        if(mode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
            WindowManager.LayoutParams winParams = win.getAttributes();
            winParams.screenBrightness = DEFAULT_CAMERA_BRIGHTNESS;
            win.setAttributes(winParams);
        } 
    } 
	 
	private void restartPreview() { 
        //In case I ever need a restart instead of just start. 
        startPreview(); 
    } 
	 
	private void stopPreview() { 
        if (this.mCameraDevice != null && this.mPreviewing) {
            Log.v(TAG, "stopPreview");
            this.mCameraDevice.stopPreview();
5
CodeRank
This code example shows how to use the following methods:getAttributes, setAttributes
        return menu;
    } 
 
    public void setFullscreen(boolean enabled) {
        Window win = mActivity.getWindow();
        WindowManager.LayoutParams winParams = win.getAttributes();
        final int bits = WindowManager.LayoutParams.FLAG_FULLSCREEN;
        if (enabled) {
            winParams.flags |=  bits;
        } else { 
            winParams.flags &= ~bits;
            if (mCustomView != null) {
                mCustomView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
            } else { 
                mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
            } 
        } 
        win.setAttributes(winParams);
    } 
 

5
CodeRank
This code example shows how to use the following methods:getAttributes, setAttributes
		// ��ʾ͸���ĶԻ��� 
		 
		AlertDialog alertDialog = new AlertDialog.Builder(this)
				.setMessage("͸���Ի���").setPositiveButton("ȷ��", null).create();
		Window window = alertDialog.getWindow();
		WindowManager.LayoutParams lp = window.getAttributes();
		//  ����͸����Ϊ0.7 
		lp.alpha = 0.7f;
		window.setAttributes(lp);
		alertDialog.show();
  
		// ��ʾ��͸���ĶԻ��� 
		alertDialog = new AlertDialog.Builder(this).setMessage("�ڵ׶���ʾ�Ի���")
				.setPositiveButton("ȷ��", null).create();
		window = alertDialog.getWindow(); 
		 
		window.setGravity(Gravity.BOTTOM);
		alertDialog.show();
	} 
} 
5
CodeRank
This code example shows how to use the following methods:getAttributes, setAttributes
	public void onClick_CustomPositionDialog(View view)
	{ 
		AlertDialog alertDialog = new AlertDialog.Builder(this).setMessage("������λ����ʾ�Ի���")
				.setPositiveButton("ȷ��", null).create();
		Window window = alertDialog.getWindow();
		WindowManager.LayoutParams lp = window.getAttributes();
		lp.x = -20;
		lp.y = -120;
		window.setAttributes(lp);
 
		alertDialog.show();
 
	} 
} 
5
CodeRank

Related Window getAttributes Questions & Answers:

getAttributes Method Overview
Retrieve the current window attributes associated with this panel.
See Code Examples for other Android Window Methods: