當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。