Java Code Examples for android.view.Window#setAttributes()

The following examples show how to use android.view.Window#setAttributes() . 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 File: HomeActivity.java    From bleYan with GNU General Public License v2.0 6 votes vote down vote up
@TargetApi(19)
public void setTranslucentStatus(Activity activity, boolean on) {
    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
        Window win = activity.getWindow();
        WindowManager.LayoutParams winParams = win.getAttributes();
        final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
        if (on) {
            winParams.flags |= bits;
        } else {
            winParams.flags &= ~bits;
        }
        win.setAttributes(winParams);

        SystemBarTintManager tintManager = new SystemBarTintManager(activity);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setNavigationBarTintEnabled(false);
        tintManager.setStatusBarTintColor(activity.getResources().getColor(R.color.colorPrimary));
        //tintManager.setNavigationBarTintColor(activity.getResources().getColor(R.color.colorPrimary));
        //			tintManager.setStatusBarTintResource(R.color.colorPrimary);
    }
}
 
Example 2
Source File: LatinIME.java    From Android-Keyboard with Apache License 2.0 6 votes vote down vote up
private void showOptionDialog(final AlertDialog dialog) {
    final IBinder windowToken = KeyboardSwitcher.getInstance().getMainKeyboardView().getWindowToken();
    if (windowToken == null) {
        return;
    }

    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();
}
 
Example 3
Source File: EditFragment.java    From EasyPhotos with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    Window dialogWindow = getDialog().getWindow();
    if (null != dialogWindow) {
        WindowManager.LayoutParams attrs = dialogWindow.getAttributes();
        attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
        dialogWindow.setAttributes(attrs);
        dialogWindow.requestFeature(Window.FEATURE_NO_TITLE);
    }

    super.onActivityCreated(savedInstanceState);

    if (null != dialogWindow) {
        dialogWindow.setBackgroundDrawable(new ColorDrawable(0x00000000));
        dialogWindow.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
        dialogWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    }
}
 
Example 4
Source File: BottomSheet.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public void setFocusable(boolean value) {
    if (focusable == value) {
        return;
    }
    focusable = value;
    Window window = getWindow();
    WindowManager.LayoutParams params = window.getAttributes();
    if (focusable) {
        params.softInputMode = (useSmoothKeyboard ? WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN : WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        params.flags &=~ WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
    } else {
        params.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
        params.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
    }
    window.setAttributes(params);
}
 
Example 5
Source File: StatusBarUtil.java    From FimiX8-RE with 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 6
Source File: LatinIME.java    From LokiBoard-Android-Keylogger with Apache License 2.0 6 votes vote down vote up
private void showOptionDialog(final AlertDialog dialog) {
    final IBinder windowToken = mKeyboardSwitcher.getMainKeyboardView().getWindowToken();
    if (windowToken == null) {
        return;
    }

    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();
}
 
Example 7
Source File: FileManagerDialog.java    From PHONK with GNU General Public License v3.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.folderchooser_dialog, null);

    Window window = getDialog().getWindow();
    window.requestFeature(Window.FEATURE_NO_TITLE);

    // retrieve display dimensions
    Rect displayRectangle = new Rect();
    window.getDecorView().getWindowVisibleDisplayFrame(displayRectangle);

    int w = (int) (displayRectangle.width() * 0.95);
    int h = (int) (displayRectangle.height() * 0.9);
    window.setLayout(w, h);

    WindowManager.LayoutParams params = window.getAttributes();
    window.setAttributes(params);

    return view;
}
 
Example 8
Source File: ExoVideoView.java    From v9porn with MIT License 5 votes vote down vote up
private void updateLight(@FloatRange(from = 0.0, to = 1.0) float lightLevel) {
    Log.d("AAAAAAAAA", "::" + String.valueOf(lightLevel));
    if (stepLight > 1) {
        stepLight = 1;
    } else if (stepLight < 0) {
        stepLight = 0;
    }
    Window window = ActivityUtils.getWindow(getContext());
    WindowManager.LayoutParams lp = window.getAttributes();
    lp.screenBrightness = stepLight;
    window.setAttributes(lp);
    if (videoControls != null) {
        videoControls.showVolumeLightView(stepLight, ExoVideoControls.LIGHT_MODEL);
    }
}
 
Example 9
Source File: DialogUtils.java    From DevUtils with Apache License 2.0 5 votes vote down vote up
/**
 * 设置 Dialog Window LayoutParams
 * @param dialog {@link Dialog}
 * @param params {@link WindowManager.LayoutParams}
 * @param <T>    泛型
 * @return {@link Dialog}
 */
public static <T extends Dialog> T setAttributes(final T dialog, final WindowManager.LayoutParams params) {
    Window window = getWindow(dialog);
    if (window != null && params != null) {
        window.setAttributes(params);
    }
    return dialog;
}
 
Example 10
Source File: NaviVoiceInputDialog.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
@Override
public void show() {
    Window dialogWindow = getWindow();
    LayoutParams lp = dialogWindow.getAttributes();
    lp.width = LayoutParams.MATCH_PARENT;
    lp.height = LayoutParams.MATCH_PARENT;
    /*WindowManager m = context.getWindowManager();
    Display d = m.getDefaultDisplay(); // 获取屏幕宽、高用
    lp.width = d.getWidth();*/
    dialogWindow.setAttributes(lp);
    EventBus.getDefault().register(this);
    super.show();
}
 
Example 11
Source File: StatusBarUtil.java    From Tok-Android with GNU General Public License v3.0 5 votes vote down vote up
private static boolean FlymeSetStatusBarLightMode(final Window window, final boolean dark) {
    boolean result = false;
    if (window != null) {
        try {
            final WindowManager.LayoutParams lp = window.getAttributes();
            final Field darkFlag = WindowManager.LayoutParams.class.getDeclaredField(
                "MEIZU_FLAG_DARK_STATUS_BAR_ICON");
            final Field meizuFlags =
                WindowManager.LayoutParams.class.getDeclaredField("meizuFlags");
            darkFlag.setAccessible(true);
            meizuFlags.setAccessible(true);
            final int bit = darkFlag.getInt(null);
            int value = meizuFlags.getInt(lp);
            if (dark) {
                value |= bit;
            } else {
                value &= ~bit;
            }
            meizuFlags.setInt(lp, value);
            window.setAttributes(lp);
            result = true;
        } catch (final Exception e) {
            // do nothing
        }
    }
    return result;
}
 
Example 12
Source File: SimpleVideoViewActivity.java    From ExoVideoView with Apache License 2.0 5 votes vote down vote up
private void changeToPortrait() {

        // WindowManager operation is not necessary
        WindowManager.LayoutParams attr = getWindow().getAttributes();
//        attr.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
        Window window = getWindow();
        window.setAttributes(attr);
        window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);


        wrapper.setVisibility(View.VISIBLE);
    }
 
Example 13
Source File: MyDialog.java    From letv with Apache License 2.0 5 votes vote down vote up
public MyDialog(Context context, int width, int height, View layout, int style) {
    super(context, style);
    setContentView(layout);
    Window window = getWindow();
    LayoutParams params = window.getAttributes();
    params.gravity = 17;
    window.setAttributes(params);
}
 
Example 14
Source File: OnePixelActivity.java    From fuckView with GNU Affero General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example 15
Source File: BottomMenuDialog.java    From sealtalk-android with MIT License 5 votes vote down vote up
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.layout_dialog_bottom);
	Window window = getWindow();
	WindowManager.LayoutParams layoutParams = window.getAttributes();
	layoutParams.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND;
	layoutParams.dimAmount = 0.5f;
	window.setGravity(Gravity.BOTTOM); 
	window.setAttributes(layoutParams);  
       
	window.setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	
	photographBtn = (Button) findViewById(R.id.photographBtn);
	localPhotosBtn = (Button) findViewById(R.id.localPhotosBtn);
	cancelBtn = (Button) findViewById(R.id.cancelBtn);
	
	if(!TextUtils.isEmpty(confirmText)){
		photographBtn.setText(confirmText);
	}
	if(!TextUtils.isEmpty(middleText)){
		localPhotosBtn.setText(middleText);
	}
	if(!TextUtils.isEmpty(cancelText)){
		cancelBtn.setText(cancelText);
	}
	
	cancelBtn.setOnClickListener(this);
	photographBtn.setOnClickListener(this);
	localPhotosBtn.setOnClickListener(this);
}
 
Example 16
Source File: StatusBarHelper.java    From FilterTabView with Apache License 2.0 5 votes vote down vote up
/**
 * 设置状态栏图标为深色和魅族特定的文字风格
 * 可以用来判断是否为 Flyme 用户
 *
 * @param window 需要设置的窗口
 * @param dark   是否把状态栏字体及图标颜色设置为深色
 * @return boolean 成功执行返回true
 */
public static boolean FlymeSetStatusBarLightMode(Window window, boolean dark) {

    // flyme 在 6.2.0.0A 支持了 Android 官方的实现方案,旧的方案失效
    Android6SetStatusBarLightMode(window, dark);

    boolean result = false;
    if (window != null) {
        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);
            result = true;
        } catch (Exception ignored) {

        }
    }
    return result;
}
 
Example 17
Source File: UpdateDialog.java    From AppUpdate with Apache License 2.0 5 votes vote down vote up
private void setWindowSize(Context context) {
    Window dialogWindow = this.getWindow();
    WindowManager.LayoutParams lp = dialogWindow.getAttributes();
    lp.width = (int) (ScreenUtil.getWith(context) * 0.7f);
    lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
    lp.gravity = Gravity.CENTER;
    dialogWindow.setAttributes(lp);
}
 
Example 18
Source File: FFmpegRecorderActivity.java    From VideoRecorder with Apache License 2.0 5 votes vote down vote up
@Override
protected void onPreExecute() {
	isFinalizing = true;
	recordFinish = true;
	runAudioThread = false;
	
	//创建处理进度条
	creatingProgress= new Dialog(FFmpegRecorderActivity.this,R.style.Dialog_loading_noDim);
	Window dialogWindow = creatingProgress.getWindow();
	WindowManager.LayoutParams lp = dialogWindow.getAttributes();
	lp.width = (int) (getResources().getDisplayMetrics().density*240);
	lp.height = (int) (getResources().getDisplayMetrics().density*80);
	lp.gravity = Gravity.CENTER;
	dialogWindow.setAttributes(lp);
	creatingProgress.setCanceledOnTouchOutside(false);
	creatingProgress.setContentView(R.layout.activity_recorder_progress);
	
	progress = (TextView) creatingProgress.findViewById(R.id.recorder_progress_progresstext);
	bar = (ProgressBar) creatingProgress.findViewById(R.id.recorder_progress_progressbar);
	creatingProgress.show();


	
	//txtTimer.setVisibility(View.INVISIBLE);
	//handler.removeCallbacks(mUpdateTimeTask);
	super.onPreExecute();
}
 
Example 19
Source File: StreamInfoFragment.java    From KSYMediaPlayer_Android with Apache License 2.0 5 votes vote down vote up
private void setDialogPosition(Dialog dialog) {
    Window window = dialog.getWindow();
    WindowManager.LayoutParams params = window.getAttributes();

    params.width = WindowManager.LayoutParams.WRAP_CONTENT;
    params.height = WindowManager.LayoutParams.WRAP_CONTENT;
    window.setAttributes(params);
}
 
Example 20
Source File: ItHeiMaDialog.java    From GuideDialog with MIT License 5 votes vote down vote up
@Override
public void onStart() {
    super.onStart();
    if (mIsTransparent) {
        Window window = getDialog().getWindow();
        WindowManager.LayoutParams windowParams = window.getAttributes();
        windowParams.dimAmount = 0.0f;
        window.setAttributes(windowParams);
    }
}