android.view.Window#setAttributes ( )源码实例Demo

下面列出了android.view.Window#setAttributes ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: PHONK   文件: FileManagerDialog.java
@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;
}
 
源代码2 项目: LokiBoard-Android-Keylogger   文件: LatinIME.java
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();
}
 
源代码3 项目: FimiX8-RE   文件: StatusBarUtil.java
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;
    }
}
 
源代码4 项目: Telegram   文件: BottomSheet.java
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);
}
 
源代码5 项目: bleYan   文件: HomeActivity.java
@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);
    }
}
 
源代码6 项目: EasyPhotos   文件: EditFragment.java
@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);
    }
}
 
源代码7 项目: Android-Keyboard   文件: LatinIME.java
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();
}
 
源代码8 项目: Tok-Android   文件: StatusBarUtil.java
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;
}
 
源代码9 项目: GuideDialog   文件: ItHeiMaDialog.java
@Override
public void onStart() {
    super.onStart();
    if (mIsTransparent) {
        Window window = getDialog().getWindow();
        WindowManager.LayoutParams windowParams = window.getAttributes();
        windowParams.dimAmount = 0.0f;
        window.setAttributes(windowParams);
    }
}
 
源代码10 项目: letv   文件: MyDialog.java
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);
}
 
源代码11 项目: AssistantBySDK   文件: NaviVoiceInputDialog.java
@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();
}
 
源代码12 项目: v9porn   文件: ExoVideoView.java
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);
    }
}
 
源代码13 项目: DevUtils   文件: DialogUtils.java
/**
 * 设置 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;
}
 
源代码14 项目: ExoVideoView   文件: SimpleVideoViewActivity.java
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);
    }
 
源代码15 项目: fuckView   文件: OnePixelActivity.java
@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);
}
 
源代码16 项目: sealtalk-android   文件: BottomMenuDialog.java
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);
}
 
源代码17 项目: FilterTabView   文件: StatusBarHelper.java
/**
 * 设置状态栏图标为深色和魅族特定的文字风格
 * 可以用来判断是否为 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;
}
 
源代码18 项目: AppUpdate   文件: UpdateDialog.java
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);
}
 
源代码19 项目: VideoRecorder   文件: FFmpegRecorderActivity.java
@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();
}
 
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);
}