本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例12: getDisplayWHHeigth
import android.app.Activity; //导入方法依赖的package包/类
public static int getDisplayWHHeigth(Activity context){
WindowManager wm = context.getWindowManager();
int height = wm.getDefaultDisplay().getHeight();
return height;
}
示例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;
}
示例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;
}