本文整理匯總了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;
}