当前位置: 首页>>代码示例>>Java>>正文


Java WindowManager.LayoutParams方法代码示例

本文整理汇总了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);

}
 
开发者ID:weileng11,项目名称:KUtils-master,代码行数:36,代码来源:ToolUtils.java

示例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();
}
 
开发者ID:coderJohnZhang,项目名称:TvSoftKeyboard,代码行数:33,代码来源:GlobalSoftKeyboard.java

示例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();
        }
    }
 
开发者ID:android-notes,项目名称:sao,代码行数:14,代码来源:MainActivity.java

示例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);
        }
    }
}
 
开发者ID:JessYanCoding,项目名称:ProgressManager,代码行数:12,代码来源:a.java

示例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();
}
 
开发者ID:gtf35,项目名称:easyShopping,代码行数:15,代码来源:BaseActivity.java

示例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);
}
 
开发者ID:NullUsera,项目名称:meipai-Android,代码行数:13,代码来源:RoundProgressDialog.java

示例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);
}
 
开发者ID:wuhighway,项目名称:UShareDemo,代码行数:8,代码来源:ShareCustomPopupWindow.java

示例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);
}
 
开发者ID:garretyoder,项目名称:Cluttr,代码行数:31,代码来源:AlbumPickerDialog.java

示例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();
    }
}
 
开发者ID:fekracomputers,项目名称:QuranAndroid,代码行数:37,代码来源:TranslationReadActivity.java

示例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);
    }
}
 
开发者ID:z-chu,项目名称:FriendBook,代码行数:13,代码来源:SystemBarUtils.java

示例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);
}
 
开发者ID:harrylefit,项目名称:EazyBaseMVP,代码行数:8,代码来源:UIUtils.java

示例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;
                    }

                }
            }
        });

/*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/

    }
 
开发者ID:HitRoxxx,项目名称:FloatingNew,代码行数:57,代码来源:CameraPreviewService.java

示例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);
}
 
开发者ID:GitLqr,项目名称:LQRWeChat,代码行数:6,代码来源:PopupWindowUtils.java

示例14: showStatusBar

import android.view.WindowManager; //导入方法依赖的package包/类
private void showStatusBar() {
    WindowManager.LayoutParams attrs = getWindow().getAttributes();
    attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
    getWindow().setAttributes(attrs);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:ImagePreviewActivity.java

示例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);
    }

}
 
开发者ID:lisnstatic,项目名称:live_master,代码行数:52,代码来源:SystemBarTintManager.java


注:本文中的android.view.WindowManager.LayoutParams方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。