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


Java Activity.getWindowManager方法代码示例

本文整理汇总了Java中android.app.Activity.getWindowManager方法的典型用法代码示例。如果您正苦于以下问题:Java Activity.getWindowManager方法的具体用法?Java Activity.getWindowManager怎么用?Java Activity.getWindowManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.Activity的用法示例。


在下文中一共展示了Activity.getWindowManager方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: navigationBarExist

import android.app.Activity; //导入方法依赖的package包/类
private boolean navigationBarExist(Activity activity) {
    WindowManager windowManager = activity.getWindowManager();
    Display d = windowManager.getDefaultDisplay();

    DisplayMetrics realDisplayMetrics = new DisplayMetrics();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        d.getRealMetrics(realDisplayMetrics);
    }

    int realHeight = realDisplayMetrics.heightPixels;
    int realWidth = realDisplayMetrics.widthPixels;

    DisplayMetrics displayMetrics = new DisplayMetrics();
    d.getMetrics(displayMetrics);

    int displayHeight = displayMetrics.heightPixels;
    int displayWidth = displayMetrics.widthPixels;

    return (realWidth - displayWidth) > 0 || (realHeight - displayHeight) > 0;
}
 
开发者ID:wavening,项目名称:TransparentBar,代码行数:21,代码来源:UltimateBar.java

示例2: getDisplayWidth

import android.app.Activity; //导入方法依赖的package包/类
public static int getDisplayWidth(Activity activity){
    int width=0;
    if (activity != null && activity.getWindowManager() != null && activity.getWindowManager().getDefaultDisplay() != null) {
        Point point=new Point();
        activity.getWindowManager().getDefaultDisplay().getSize(point);
        width = point.x;
    }
    return width;
}
 
开发者ID:osmartian,项目名称:martian-cli,代码行数:10,代码来源:CommonUtils.java

示例3: zoomy

import android.app.Activity; //导入方法依赖的package包/类
/**
 * 计算按照屏幕比例缩放后的尺寸
 * @param sizey
 * @return
 */
public int zoomy(Activity activity, int sizey){
    float heightP=1920.0f;
    if(fzoomy == 0f){
        WindowManager windowManager = activity.getWindowManager();
        Display display = windowManager.getDefaultDisplay();
        DisplayMetrics metrics = new DisplayMetrics();
        display.getMetrics(metrics);
        fzoomy = (metrics.heightPixels/heightP)*sizey+10;
    }
    return (int)(fzoomy);
}
 
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:17,代码来源:OvSlideViewpager.java

示例4: zoomx

import android.app.Activity; //导入方法依赖的package包/类
/**
 * 计算按照屏幕比例缩放后的尺寸
 * @param sizex
 * @return
 */
public int zoomx(Activity activity, int sizex){
    float widthP=1080.0f;
    if(fzoomx == 0f){
        WindowManager windowManager = activity.getWindowManager();
        Display display = windowManager.getDefaultDisplay();
        DisplayMetrics metrics = new DisplayMetrics();
        display.getMetrics(metrics);
        fzoomx = (metrics.widthPixels/widthP)*sizex+10;
    }
    return (int)(fzoomx);
}
 
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:17,代码来源:OvSlideViewpager.java

示例5: getDisplayHeight

import android.app.Activity; //导入方法依赖的package包/类
public static int getDisplayHeight(Activity activity) {
    int height = 0;
    if (activity != null && activity.getWindowManager() != null && activity.getWindowManager().getDefaultDisplay() != null) {
        Point point=new Point();
        activity.getWindowManager().getDefaultDisplay().getSize(point);
        height=point.y;
    }

    Log.e(TAG, "isSupportSmartBar:" + isSupportSmartBar);

    if (isSupportSmartBar) {
        int smartBarHeight = getSmartBarHeight(activity);
        Log.e(TAG, "smartBarHeight:" + smartBarHeight);
        height -= smartBarHeight;
    }

    if (activity != null && activity.getActionBar() != null) {
      int actionbar= activity.getActionBar().getHeight();
      if(actionbar==0){
        TypedArray actionbarSizeTypedArray=activity.obtainStyledAttributes(new int[]{android.R.attr.actionBarSize});
        actionbar= (int) actionbarSizeTypedArray.getDimension(0,0);
      }
      Log.d(TAG, "actionbar:" + actionbar);
      height -= actionbar;
    }

    int status = getStatusBarHeight(activity);
    Log.d(TAG, "status:" + status);

    height -= status;

    Log.d(TAG,"height:"+height);
    return height;
}
 
开发者ID:wangwei123,项目名称:my-weex,代码行数:35,代码来源:CommonUtils.java

示例6: getScreenHeight

import android.app.Activity; //导入方法依赖的package包/类
public static  int getScreenHeight(Activity context){
    DisplayMetrics metrics=new DisplayMetrics();
    WindowManager manager= context.getWindowManager();
    manager.getDefaultDisplay().getMetrics(metrics);
    int h=metrics.heightPixels;
    return h;
}
 
开发者ID:ebridfighter,项目名称:GongXianSheng,代码行数:8,代码来源:DensityUtil.java

示例7: showButton

import android.app.Activity; //导入方法依赖的package包/类
void showButton(Activity activity, boolean animated) {
    WindowManager windowManager = activity.getWindowManager();
    final View button = createButton();
    buttons.put(activity, button);
    final LayoutParams wrap = wrap(BUTTON_PARAMS);
    windowManager.addView(button, wrap);
    dragHelper.manage(windowManager, button);
    if (animated) {
        dragHelper.animateFromDefaultPosition(button, null);
    }
}
 
开发者ID:roshakorost,项目名称:Phial,代码行数:12,代码来源:OverlayView.java

示例8: getScreenH

import android.app.Activity; //导入方法依赖的package包/类
public static  int getScreenH(Activity context) {
    DisplayMetrics metrics = new DisplayMetrics();
    WindowManager manager = context.getWindowManager();
    manager.getDefaultDisplay().getMetrics(metrics);
    int w = metrics.heightPixels;
    return w;
}
 
开发者ID:ebridfighter,项目名称:GongXianSheng,代码行数:8,代码来源:DensityUtil.java

示例9: getRealScreenHeight

import android.app.Activity; //导入方法依赖的package包/类
/**
 * 获取屏幕高度,包括底部导航栏
 *
 * @param activity
 * @return
 */
public static int getRealScreenHeight(Activity activity) {
    WindowManager windowManager = activity.getWindowManager();
    Display display = windowManager.getDefaultDisplay();
    DisplayMetrics displayMetrics = new DisplayMetrics();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        display.getRealMetrics(displayMetrics);
    } else {
        display.getMetrics(displayMetrics);
    }
    return displayMetrics.heightPixels;
}
 
开发者ID:zhudongya123,项目名称:WechatChatroomHelper,代码行数:18,代码来源:UIUtil.java

示例10: getScreenHeight

import android.app.Activity; //导入方法依赖的package包/类
/**
 * 获取屏幕的高度
 *
 * @param activity
 * @return
 */
public static int getScreenHeight(Activity activity) {
    WindowManager manager = activity.getWindowManager();
    DisplayMetrics outMetrics = new DisplayMetrics();
    manager.getDefaultDisplay().getMetrics(outMetrics);
    return outMetrics.heightPixels;
}
 
开发者ID:lanyuanxiaoyao,项目名称:PicKing,代码行数:13,代码来源:ScreenUtil.java

示例11: zoomForFilePath

import android.app.Activity; //导入方法依赖的package包/类
public static Bitmap zoomForFilePath(Activity context, String filePath) {
    Bitmap bitmap = BitmapFactory.decodeFile(filePath);
    BitmapFactory.Options opt = new BitmapFactory.Options();
    //这个isjustdecodebounds很重要
    opt.inJustDecodeBounds = true;

    //获取到这个图片的原始宽度和高度
    int picWidth = bitmap.getWidth();
    int picHeight = bitmap.getHeight();

    //获取屏的宽度和高度
    WindowManager windowManager = context.getWindowManager();
    Display display = windowManager.getDefaultDisplay();
    int screenWidth = display.getWidth();
    int screenHeight = display.getHeight();

    //isSampleSize是表示对图片的缩放程度,比如值为2图片的宽度和高度都变为以前的1/2
    opt.inSampleSize = 1;
    //根据屏的大小和图片大小计算出缩放比例
    if (picWidth > picHeight) {
        if (picWidth > screenWidth)
            opt.inSampleSize = picWidth / screenWidth;
    } else {
        if (picHeight > screenHeight)
            opt.inSampleSize = picHeight / screenHeight;
    }

    //这次再真正地生成一个有像素的,经过缩放了的bitmap
    opt.inJustDecodeBounds = false;
    bitmap = BitmapFactory.decodeFile(filePath, opt);
    return bitmap;
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:33,代码来源:ImageUtils.java

示例12: getDisplayWHHeigth

import android.app.Activity; //导入方法依赖的package包/类
public static int getDisplayWHHeigth(Activity context){
    WindowManager wm = context.getWindowManager();

    int height = wm.getDefaultDisplay().getHeight();
    return height;
}
 
开发者ID:xiaoxiaoqingyi,项目名称:VRPhoto,代码行数:7,代码来源:Utils.java

示例13: getScreenBitmap

import android.app.Activity; //导入方法依赖的package包/类
public static Bitmap getScreenBitmap(Activity mActivity) {

		WindowManager windowManager = mActivity.getWindowManager();

		Display display = windowManager.getDefaultDisplay();

		int w = display.getWidth();

		int h = display.getHeight();

		Bitmap bitmap = Bitmap.createBitmap(w, h, Config.ARGB_8888);

		// 获取屏幕

		View decorview = mActivity.getWindow().getDecorView();

		decorview.setDrawingCacheEnabled(true);

		bitmap = decorview.getDrawingCache();
		decorview.setDrawingCacheEnabled(false);

		return bitmap;
	}
 
开发者ID:zhuyu1022,项目名称:amap,代码行数:24,代码来源:ScreenUtils.java

示例14: getCurrentImage

import android.app.Activity; //导入方法依赖的package包/类
public static Bitmap getCurrentImage(Activity mActivity) {
		LogUtil.i("=======  getCurrentImage 01");
		// 构建Bitmap

		WindowManager windowManager = mActivity.getWindowManager();

		Display display = windowManager.getDefaultDisplay();

		int w = display.getWidth();

		int h = display.getHeight();

		Bitmap Bmp = Bitmap.createBitmap(w, h, Config.ARGB_8888);
		LogUtil.i("=======  getCurrentImage 02");
		// 获取屏幕

		View decorview = mActivity.getWindow().getDecorView();

		decorview.setDrawingCacheEnabled(true);

		Bmp = decorview.getDrawingCache();
//		if (Bmp != null) {
//			Bmp.recycle();
//			Bmp = null;
//		}
		
		LogUtil.i("=======  getCurrentImage 04");
		decorview.setDrawingCacheEnabled(false);
		LogUtil.i("=======  getCurrentImage 05");
		
		
		return Bmp;

	}
 
开发者ID:zhuyu1022,项目名称:amap,代码行数:35,代码来源:ScreenUtils.java


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