本文整理汇总了Java中android.view.Display.getRealSize方法的典型用法代码示例。如果您正苦于以下问题:Java Display.getRealSize方法的具体用法?Java Display.getRealSize怎么用?Java Display.getRealSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.Display
的用法示例。
在下文中一共展示了Display.getRealSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setWindowDecorations
import android.view.Display; //导入方法依赖的package包/类
public static void setWindowDecorations(Activity activity, SharedPreferences options) {
if (Build.VERSION.SDK_INT >= 21) {
activity.getWindow().setStatusBarColor(options.getInt(Keys.STATUS_BAR_BACKGROUND, 0x22000000));
activity.getWindow().setNavigationBarColor(options.getInt(Keys.NAV_BAR_BACKGROUND, 0x22000000));
} else {
activity.findViewById(R.id.dummy_top_view).setBackgroundColor(options.getInt(Keys.BAR_BACKGROUND, 0x22000000));
Display display = ((WindowManager)activity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
Point size = new Point();
Point realSize = new Point();
display.getSize(size);
display.getRealSize(realSize);
int navBarHeight = size.y-realSize.y;
View dummyBottomView = activity.findViewById(R.id.dummy_bottom_view);
ViewGroup.LayoutParams p = dummyBottomView.getLayoutParams();
p.height = navBarHeight;
dummyBottomView.setLayoutParams(p);
if (navBarHeight > 0) {
dummyBottomView.setVisibility(View.VISIBLE);
dummyBottomView.setBackgroundColor(options.getInt(Keys.NAV_BAR_BACKGROUND, 0x22000000));
}
}
}
示例2: getResolution
import android.view.Display; //导入方法依赖的package包/类
/**
* @return 获取屏幕分辨率
*/
public static Point getResolution(Context context) {
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics outMetrics = new DisplayMetrics();
Display display = wm.getDefaultDisplay();
display.getMetrics(outMetrics);
Point point = new Point();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
display.getRealSize(point);
} else {
point.x = outMetrics.widthPixels;
point.y = outMetrics.heightPixels;
}
return point;
}
示例3: isNavigationBarShow
import android.view.Display; //导入方法依赖的package包/类
public static boolean isNavigationBarShow(Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
Display display = activity.getWindowManager().getDefaultDisplay();
Point size = new Point();
Point realSize = new Point();
display.getSize(size);
display.getRealSize(realSize);
return realSize.y != size.y;
} else {
boolean menu = ViewConfiguration.get(activity).hasPermanentMenuKey();
boolean back = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
if (menu || back) {
return false;
} else {
return true;
}
}
}
示例4: setCustomNotifBgLandscape
import android.view.Display; //导入方法依赖的package包/类
private void setCustomNotifBgLandscape() {
Display display = getActivity().getWindowManager().getDefaultDisplay();
Point displaySize = new Point();
display.getRealSize(displaySize);
Intent intent = new Intent(getActivity(), PickImageActivity.class);
intent.putExtra(PickImageActivity.EXTRA_CROP, true);
boolean isPortrait = getResources()
.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
intent.putExtra(PickImageActivity.EXTRA_ASPECT_X, isPortrait ? displaySize.y : displaySize.x);
intent.putExtra(PickImageActivity.EXTRA_ASPECT_Y, isPortrait ? displaySize.x : displaySize.y);
intent.putExtra(PickImageActivity.EXTRA_OUTPUT_X, isPortrait ? displaySize.y : displaySize.x);
intent.putExtra(PickImageActivity.EXTRA_OUTPUT_Y, isPortrait ? displaySize.x : displaySize.y);
intent.putExtra(PickImageActivity.EXTRA_SCALE, true);
intent.putExtra(PickImageActivity.EXTRA_SCALE_UP, true);
startActivityForResult(intent, REQ_NOTIF_BG_IMAGE_LANDSCAPE);
}
示例5: b
import android.view.Display; //导入方法依赖的package包/类
@SuppressLint({"NewApi"})
public static Point b() {
Display defaultDisplay = ((WindowManager) hn.a().c().getSystemService("window")).getDefaultDisplay();
Point point = new Point();
if (VERSION.SDK_INT >= 17) {
defaultDisplay.getRealSize(point);
} else if (VERSION.SDK_INT >= 14) {
try {
Method method = Display.class.getMethod("getRawHeight", new Class[0]);
point.x = ((Integer) Display.class.getMethod("getRawWidth", new Class[0]).invoke(defaultDisplay, new Object[0])).intValue();
point.y = ((Integer) method.invoke(defaultDisplay, new Object[0])).intValue();
} catch (Throwable th) {
defaultDisplay.getSize(point);
}
} else if (VERSION.SDK_INT >= 13) {
defaultDisplay.getSize(point);
} else {
point.x = defaultDisplay.getWidth();
point.y = defaultDisplay.getHeight();
}
return point;
}
示例6: getRealScreenSize
import android.view.Display; //导入方法依赖的package包/类
public static Point getRealScreenSize(Context context) {
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = windowManager.getDefaultDisplay();
Point size = new Point();
if (Build.VERSION.SDK_INT >= 17) {
display.getRealSize(size);
} else {
try {
size.x = (Integer) Display.class.getMethod("getRawWidth").invoke(display);
size.y = (Integer) Display.class.getMethod("getRawHeight").invoke(display);
} catch (Exception e) {
e.printStackTrace();
}
}
return size;
}
示例7: getRealScreenSize
import android.view.Display; //导入方法依赖的package包/类
private static Point getRealScreenSize(@NonNull Context context) {
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = windowManager.getDefaultDisplay();
Point size = new Point();
if (Build.VERSION.SDK_INT >= 17) {
display.getRealSize(size);
} else if (Build.VERSION.SDK_INT >= 14) {
try {
size.x = (Integer) Display.class.getMethod("getRawWidth").invoke(display);
size.y = (Integer) Display.class.getMethod("getRawHeight").invoke(display);
} catch (Exception e) {
LogUtil.e(Log.getStackTraceString(e));
}
}
return size;
}
示例8: NaskhPageProvider
import android.view.Display; //导入方法依赖的package包/类
public NaskhPageProvider(@NonNull Display display) {
final Point point = new Point();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
display.getRealSize(point);
} else {
try {
// getRealSize was actually present since 4.0, but was annotated @hide.
Display.class.getMethod("getRealSize", Point.class).invoke(display, point);
} catch (Exception e) {
display.getSize(point);
}
}
mRatioIndex = getScreenRatioIndex(point.x, point.y);
}
示例9: getScreenHeightWidth
import android.view.Display; //导入方法依赖的package包/类
public static Point getScreenHeightWidth(WindowManager mWindowManager) {
Point point = new Point();
try {
Display display = mWindowManager.getDefaultDisplay();
if (VERSION.SDK_INT >= 17) {
display.getRealSize(point);
} else {
point.y = display.getHeight();
point.x = display.getWidth();
}
} catch (Throwable e) {
LOG.w(TAG, "getScreenHeightWidth failed(Throwable): " + e.getMessage());
}
return point;
}
示例10: getWidth
import android.view.Display; //导入方法依赖的package包/类
public static int getWidth(Context context) {
WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Point size = new Point();
Display display = manager.getDefaultDisplay();
display.getRealSize(size);
return size.x;
}
示例11: updateSubsSize
import android.view.Display; //导入方法依赖的package包/类
public void updateSubsSize(){
if(mSize>=0) {
Display display = mWindowManager.getDefaultDisplay();
Point point = new Point();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
display.getRealSize(point);
display.getSize(point);
int size = (int) ((mParamsF.width / (float)(point.y<point.x ?point.x:point.y)) * mSize);
int vpos = (int) ((mParamsF.height / (float)(point.y<point.x ?point.y:point.x)) * mVPos);
mSubtitleManager.setSize(size);
mSubtitleManager.setVerticalPosition(vpos);
}
}
示例12: setUpVirtualDisplay
import android.view.Display; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void setUpVirtualDisplay() {
mScreen = (ViewGroup) getActivity().getWindow().getDecorView().getRootView();
// display metrics
DisplayMetrics metrics = getResources().getDisplayMetrics();
mDensity = metrics.densityDpi;
Display mDisplay = getActivity().getWindowManager().getDefaultDisplay();
Point size = new Point();
mDisplay.getRealSize(size);
mWidth = size.x;
mHeight = size.y;
// start capture reader
mImageReader = ImageReader.newInstance(mWidth, mHeight, PixelFormat.RGBA_8888, 2);
int flags = DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR;
mVirtualDisplay = mMediaProjection.createVirtualDisplay("ScreenCapture", mWidth, mHeight, mDensity, flags, mImageReader.getSurface(), null, null);
size.set(mWidth, mHeight);
//create ScreenCapturer
mScreenCapturer = new ScreenSharingCapturer(getActivity(), mScreen, mImageReader);
mListener.onScreenCapturerReady();
}
示例13: getRealScreenSize
import android.view.Display; //导入方法依赖的package包/类
private static Point getRealScreenSize(Context context) {
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = windowManager.getDefaultDisplay();
Point size = new Point();
display.getRealSize(size);
return size;
}
示例14: getRealSize
import android.view.Display; //导入方法依赖的package包/类
public static void getRealSize(Display display, Point outSize) {
display.getRealSize(outSize);
}
示例15: getDisplaySizeV17
import android.view.Display; //导入方法依赖的package包/类
@TargetApi(17)
private static void getDisplaySizeV17(Display display, Point outSize) {
display.getRealSize(outSize);
}