本文整理匯總了Java中android.view.WindowManager.LayoutParams方法的典型用法代碼示例。如果您正苦於以下問題:Java WindowManager.LayoutParams方法的具體用法?Java WindowManager.LayoutParams怎麽用?Java WindowManager.LayoutParams使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.view.WindowManager
的用法示例。
在下文中一共展示了WindowManager.LayoutParams方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setDialogStyle
import android.view.WindowManager; //導入方法依賴的package包/類
public static void setDialogStyle(Context context, Dialog dialog, int measuredHeight, BuildBean bean) {
if (dialog == null) {
return;
}
Window window = dialog.getWindow();
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
window.setGravity(bean.gravity);
WindowManager.LayoutParams wl = window.getAttributes();
// 以下這兩句是為了保證按鈕可以水平滿屏
int width = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth();
int height = (int) (((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getHeight() * 0.9);
if (bean.type != CommonConfig.TYPE_MD_LOADING_VERTICAL) {
wl.width = (int) (width * 0.94); // todo keycode to keep gap
} else {
wl.width = ViewGroup.LayoutParams.WRAP_CONTENT;
}
wl.height = ViewGroup.LayoutParams.WRAP_CONTENT; //TODO 一般情況下為wrapcontent,最大值為height*0.9
if (measuredHeight > height) {
wl.height = height;
}
if (context instanceof Activity) {
Activity activity1 = (Activity) context;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
if (activity1.isDestroyed()) {
context = DialogUIUtils.appContext;
}
}
} else {
wl.type = WindowManager.LayoutParams.TYPE_TOAST;
//todo keycode to improve window level,同時要讓它的後麵半透明背景也攔截事件,不要傳遞到下麵去
//todo 單例化,不然連續彈出兩次,隻能關掉第二次的
}
dialog.onWindowAttributesChanged(wl);
}
示例2: GlobalSoftKeyboard
import android.view.WindowManager; //導入方法依賴的package包/類
public GlobalSoftKeyboard(Context context, String text, int maxLen, int iType,
WindowManager.LayoutParams params, boolean bUrl) {
super(context, R.style.ThemeKeyboard);
this.context = context;
if (text == null) {
this.text = "";
}
this.text = text;
this.iMaxLength = maxLen;
if (params != null) {
this.layoutParams = params;
}
assert text != null;
iCurTextCursor = text.length();
this.bUrl = bUrl;
keyLanguageList = context.getResources().getStringArray(R.array.menu_language);
btnList = new ArrayList<>();
imageBtnList = new ArrayList<>();
bCapSwitch = false;
if (iType <= SYMBOL_KEYBOARD || iType >= ALPHABET_KEYBOARD) {
keyboardType = iType;
} else {
keyboardType = ALPHABET_KEYBOARD;
}
initKeyboard();
setKeyGroupListener();
}
示例3: showWindow
import android.view.WindowManager; //導入方法依賴的package包/類
private void showWindow() {
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
// layoutParams.type = WindowManager.LayoutParams.TYPE_TOAST;
layoutParams.type = TYPE_SYSTEM_OVERLAY;
layoutParams.flags = WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | FLAG_NOT_FOCUSABLE | FLAG_NOT_TOUCHABLE | FLAG_NOT_TOUCH_MODAL;
layoutParams.format = PixelFormat.RGBA_8888;
try {
windowManagermanager.addView(marquee, layoutParams);
} catch (Exception e) {
e.printStackTrace();
}
}
示例4: onWindowAttributesChanged
import android.view.WindowManager; //導入方法依賴的package包/類
public void onWindowAttributesChanged(WindowManager.LayoutParams params) {
// Update window manager if: we have a view, that view is
// attached to its parent (which will be a RootView), and
// this activity is not embedded.
if (mParent == null) {
View decor = mDecor;
if (decor != null && decor.getParent() != null) {
getWindowManager().updateViewLayout(decor, params);
}
}
}
示例5: onCreate
import android.view.WindowManager; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
ActivityCollector.addActivity(this);
// 這句很關鍵,注意是調用父類的方法
super.setContentView(R.layout.activity_base);
// 經測試在代碼裏直接聲明透明狀態欄更有效
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
WindowManager.LayoutParams localLayoutParams = getWindow().getAttributes();
localLayoutParams.flags = (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | localLayoutParams.flags);
}
initToolbar();
}
示例6: RoundProgressDialog
import android.view.WindowManager; //導入方法依賴的package包/類
public RoundProgressDialog(Context context) {
super(context, R.style.normal_dialog_white);
setContentView(R.layout.dialog_progress);
ButterKnife.bind(this);
progressBar.setMax(100);
Window window = getWindow();
WindowManager.LayoutParams lp = window.getAttributes();
lp.width = DensityUtil.getScreenWidth(context) * 8 / 10;//寬高可設置具體大小
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
window.setAttributes(lp);
}
示例7: setWindowAlpha
import android.view.WindowManager; //導入方法依賴的package包/類
private void setWindowAlpha(float alpha) {
Window window = activity.getWindow();
WindowManager.LayoutParams params = window.getAttributes();
params.alpha = alpha;
window.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
window.setAttributes(params);
}
示例8: onCreate
import android.view.WindowManager; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.dialog_album_picker);
ButterKnife.bind(this);
realm = Realm.getDefaultInstance();
setCancelable(false);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
Window window = getWindow();
lp.copyFrom(window.getAttributes());
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
window.setAttributes(lp);
toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_48px);
toolbar.setNavigationOnClickListener(this);
toolbar.setTitle(R.string.select_album);
adapter = new AlbumAdapter(getContext(), getResults());
recycler.setLayoutManager(new GridLayoutManager(getContext(),2));
recycler.setAdapter(adapter);
adapter.getOnClickObservable().subscribe(this);
}
示例9: onSensorChanged
import android.view.WindowManager; //導入方法依賴的package包/類
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
try {
Log.i("Sensor Changed", "Accuracy :" + sensorEvent.values[0]);
float s = sensorEvent.values[0];
String ss = String.valueOf(s);
if (ss.equals("0.0") ) { //even reduce
//refreshes the screen
int br = Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS);
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = (float) 10 / 255;
getWindow().setAttributes(lp);
} else{
//refreshes the screen
WindowManager.LayoutParams lp1 = getWindow().getAttributes();
lp1.screenBrightness = (float) 255 / 255;
getWindow().setAttributes(lp1);
}
} catch (Exception e)
{
//Throw an error case it couldn't be retrieved
Log.e("Error", "Cannot access system brightness");
e.printStackTrace();
}
}
示例10: transparentStatusBar
import android.view.WindowManager; //導入方法依賴的package包/類
public static void transparentStatusBar(Activity activity){
if (Build.VERSION.SDK_INT >= 21){
expandStatusBar(activity);
activity.getWindow()
.setStatusBarColor(activity.getResources().getColor(android.R.color.transparent));
}
else if (Build.VERSION.SDK_INT >= 19){
WindowManager.LayoutParams attrs = activity.getWindow().getAttributes();
attrs.flags = (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | attrs.flags);
activity.getWindow().setAttributes(attrs);
}
}
示例11: statuInScreen
import android.view.WindowManager; //導入方法依賴的package包/類
public static void statuInScreen(Activity activity) {
WindowManager.LayoutParams attrs = activity.getWindow().getAttributes();
attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
activity.getWindow().setAttributes(attrs);
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
示例12: onCreate
import android.view.WindowManager; //導入方法依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
// positionPreference = getSharedPreferences("Position", Context.MODE_PRIVATE);
/* windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);*/
p = new Point();
Display d = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
d.getSize(p);
mFloatingView = LayoutInflater.from(this).inflate(R.layout.camera_preview, null);
textureView = (TextureView) mFloatingView.findViewById(R.id.texture);
params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);
params.gravity = Gravity.TOP | Gravity.START; //Initially view will be added to top-left corner
params.x = 0; //-60;
params.y = 100;
setPreview();
//Add the view to the window
mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
mWindowManager.addView(mFloatingView, params);
mFloatingView.findViewById(R.id.root_container).setOnTouchListener(new Movement());
mFloatingView.findViewById(R.id.root_container).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (movmentFlag) {
if (!cameraFlag) {
textureView.setVisibility(View.INVISIBLE);
// closeCamera();
// stopBackgroundThread();
cameraFlag = true;
} else {
textureView.setVisibility(View.VISIBLE);
// setPreview();
cameraFlag = false;
}
}
}
});
/*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
}
示例13: makeWindowDark
import android.view.WindowManager; //導入方法依賴的package包/類
public static void makeWindowDark(Activity activity, float alpha) {
WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
lp.alpha = alpha;
activity.getWindow().setAttributes(lp);
}
示例14: showStatusBar
import android.view.WindowManager; //導入方法依賴的package包/類
private void showStatusBar() {
WindowManager.LayoutParams attrs = getWindow().getAttributes();
attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
getWindow().setAttributes(attrs);
}
示例15: SystemBarTintManager
import android.view.WindowManager; //導入方法依賴的package包/類
/**
* Constructor. Call this in the host activity onCreate method after its
* content view has been set. You should always create new instances when
* the host activity is recreated.
*
* @param activity The host activity.
*/
@TargetApi(19)
public SystemBarTintManager(Activity activity) {
Window win = activity.getWindow();
ViewGroup decorViewGroup = (ViewGroup) win.getDecorView();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// check theme attrs
int[] attrs = {android.R.attr.windowTranslucentStatus,
android.R.attr.windowTranslucentNavigation};
TypedArray a = activity.obtainStyledAttributes(attrs);
try {
mStatusBarAvailable = a.getBoolean(0, false);
mNavBarAvailable = a.getBoolean(1, false);
} finally {
a.recycle();
}
// check window flags
WindowManager.LayoutParams winParams = win.getAttributes();
int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
if ((winParams.flags & bits) != 0) {
mStatusBarAvailable = true;
}
bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
if ((winParams.flags & bits) != 0) {
mNavBarAvailable = true;
}
}
mConfig = new SystemBarConfig(activity, mStatusBarAvailable, mNavBarAvailable);
// device might not have virtual navigation keys
if (!mConfig.hasNavigtionBar()) {
mNavBarAvailable = false;
}
if (mStatusBarAvailable) {
setupStatusBarView(activity, decorViewGroup);
}
if (mNavBarAvailable) {
setupNavBarView(activity, decorViewGroup);
}
}