本文整理汇总了Java中android.view.Display类的典型用法代码示例。如果您正苦于以下问题:Java Display类的具体用法?Java Display怎么用?Java Display使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Display类属于android.view包,在下文中一共展示了Display类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: populate
import android.view.Display; //导入依赖的package包/类
public static void populate(Context context, View view, Display display) {
View da = view.findViewById(R.id.display_attributes);
Resources res = context.getResources();
if (da != null) {
DisplayMetrics metrics = new DisplayMetrics();
display.getMetrics(metrics);
((TextView) da.findViewById(R.id.density))
.setText(String.format("%s (%f)",
res.getString(R.string.density), metrics.density));
((TextView) da.findViewById(R.id.size)).setText(res
.getString(R.string.size));
((TextView) da.findViewById(R.id.dimensions))
.setText(String
.format("%dx%d (%dx%d)",
metrics.widthPixels,
metrics.heightPixels,
(int) ((float) metrics.widthPixels / metrics.density),
(int) ((float) metrics.heightPixels / metrics.density)));
}
}
示例2: init
import android.view.Display; //导入依赖的package包/类
private void init() {
// init surfaceholder
SurfaceHolder holder = getHolder();
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
holder.addCallback(this);
WindowManager manager = (WindowManager) getContext().getSystemService(
Context.WINDOW_SERVICE);
Display display = manager.getDefaultDisplay();
screenWidth = display.getWidth();
screenHeight = display.getHeight();
int width = screenWidth >= screenHeight ? screenWidth : screenHeight;
int height = screenWidth + screenHeight - width;
int rotation = display.getRotation();
mScanner = CameraScanner.getInstance();
mScanner.setRotation(0); //此处直接设为0,配合竖屏展示
mScanner.setReqSize(width, height);
}
示例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: checkForUpdate
import android.view.Display; //导入依赖的package包/类
public void checkForUpdate() {
//Check for update
new AppUpdater(this)
.setUpdateFrom(UpdateFrom.XML)
.setUpdateXML("https://raw.githubusercontent.com/Bella-Assistant/Bella-Android/alpha/update-changelog.xml")
.setTitleOnUpdateNotAvailable("Update not available")
.setContentOnUpdateNotAvailable("No update available. Check for updates again later!")
.setDisplay(com.github.javiersantos.appupdater.enums.Display.DIALOG)
.showAppUpdated(true)
.start();
}
示例5: setUpStatusLabel
import android.view.Display; //导入依赖的package包/类
public void setUpStatusLabel() {
MainActivity Parent = this; // Too lazy to rename
if (Parent._btn != null) {
Parent._layout2.removeView(Parent._btn);
Parent._btn = null;
}
if (Parent._tv == null) {
//Get the display so we can know the screen size
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
Parent._tv = new TextView(Parent);
Parent._tv.setMaxLines(2); // To show some long texts on smaller devices
Parent._tv.setMinLines(2); // Otherwise the background picture is getting resized at random, which does not look good
Parent._tv.setText(R.string.init);
// Padding is a good idea because if the display device is a TV the edges might be cut off
Parent._tv.setPadding((int) (width * 0.1), (int) (height * 0.1), (int) (width * 0.1), 0);
Parent._layout2.addView(Parent._tv);
}
}
示例6: checkDisplaySize
import android.view.Display; //导入依赖的package包/类
public static void checkDisplaySize() {
try {
Configuration configuration = applicationContext.getResources()
.getConfiguration();
usingHardwareInput = configuration.keyboard != Configuration.KEYBOARD_NOKEYS
&& configuration.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO;
WindowManager manager = (WindowManager) applicationContext
.getSystemService(Context.WINDOW_SERVICE);
if (manager != null) {
Display display = manager.getDefaultDisplay();
if (display != null) {
display.getMetrics(displayMetrics);
display.getSize(displaySize);
Log.d("tmessages", "display size = " + displaySize.x + " " + displaySize.y + " "
+ displayMetrics.xdpi + "x" + displayMetrics.ydpi);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例7: showFirstRunSimpleCling
import android.view.Display; //导入依赖的package包/类
public void showFirstRunSimpleCling(boolean animate) {
// Enable the clings only if they have not been dismissed before
if(isClingsEnabled() && !CalculatorSettings.isDismissed(getContext(), Cling.SIMPLE_CLING_DISMISSED_KEY)) {
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int[] location = new int[3];
location[0] = 0;
location[1] = size.y / 2;
location[2] = 10;
initCling(R.id.simple_cling, location, 0, true, animate);
}
else {
removeCling(R.id.simple_cling);
}
}
示例8: initFromCameraParameters
import android.view.Display; //导入依赖的package包/类
public void initFromCameraParameters(Camera camera) {
Camera.Parameters parameters = camera.getParameters();
WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = manager.getDefaultDisplay();
Point theScreenResolution = new Point();
theScreenResolution = getDisplaySize(display);
screenResolution = theScreenResolution;
Log.i(TAG, "Screen resolution: " + screenResolution);
/** 因为换成了竖屏显示,所以不替换屏幕宽高得出的预览图是变形的 */
Point screenResolutionForCamera = new Point();
screenResolutionForCamera.x = screenResolution.x;
screenResolutionForCamera.y = screenResolution.y;
if (screenResolution.x < screenResolution.y) {
screenResolutionForCamera.x = screenResolution.y;
screenResolutionForCamera.y = screenResolution.x;
}
cameraResolution = findBestPreviewSizeValue(parameters, screenResolutionForCamera);
Log.i(TAG, "Camera resolution x: " + cameraResolution.x);
Log.i(TAG, "Camera resolution y: " + cameraResolution.y);
}
示例9: centerWindow
import android.view.Display; //导入依赖的package包/类
private static void centerWindow(Window w) {
DisplayMetrics metrics = new DisplayMetrics();
Display display = w.getWindowManager().getDefaultDisplay();
display.getMetrics(metrics);
int width = Math.min(metrics.widthPixels - (int) (2 * DLG_PADDING_DP * metrics.density),
(int) (MAX_DIALOG_WIDTH_DP * metrics.density));
int height = Math.min(metrics.heightPixels - (int) ((2 * DLG_PADDING_DP + APPROX_STATUSBAR_HEIGHT_DP) * metrics.density),
(int) (MAX_DIALOG_HEIGHT_DP * metrics.density));
int x = (metrics.widthPixels - width) / 2;
int y = (metrics.heightPixels - height - ((int) (APPROX_STATUSBAR_HEIGHT_DP * metrics.density))) / 2;
LayoutParams params = w.getAttributes();
params.x = x;
params.y = y;
params.width = width;
params.height = height;
w.setAttributes(params);
w.setGravity(Gravity.LEFT | Gravity.TOP);
}
示例10: setUpWindow
import android.view.Display; //导入依赖的package包/类
public void setUpWindow() {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND,
WindowManager.LayoutParams.FLAG_DIM_BEHIND);
WindowManager.LayoutParams params = getWindow().getAttributes();
params.alpha = 1.0f;
params.dimAmount = 0.4f;
getWindow().setAttributes(params);
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;
if (height > width) {
getWindow().setLayout((int) (width * .9), (int) (height * .7));
} else {
getWindow().setLayout((int) (width * .7), (int) (height * .8));
}
}
示例11: create
import android.view.Display; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public AlertDialog create() {
AlertDialog alertDialog = super.create();
Window window = alertDialog.getWindow();
if (window != null) {
window.setGravity(Gravity.BOTTOM);
WindowManager m = window.getWindowManager();
Display d = m.getDefaultDisplay();
WindowManager.LayoutParams p = window.getAttributes();
p.width = d.getWidth();
window.setAttributes(p);
}
this.mAlertDialog = alertDialog;
return alertDialog;
}
示例12: initFromCameraParameters
import android.view.Display; //导入依赖的package包/类
/**
* Reads, one time, values from the camera that are needed by the app.
*/
void initFromCameraParameters(Camera camera) {
Camera.Parameters parameters = camera.getParameters();
previewFormat = parameters.getPreviewFormat();
previewFormatString = parameters.get("preview-format");
WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = manager.getDefaultDisplay();
screenResolution = new Point(display.getWidth(), display.getHeight());
Point screenResolutionForCamera = new Point();
screenResolutionForCamera.x = screenResolution.x;
screenResolutionForCamera.y = screenResolution.y;
// preview size is always something like 480*320, other 320*480
if (screenResolution.x < screenResolution.y) {
screenResolutionForCamera.x = screenResolution.y;
screenResolutionForCamera.y = screenResolution.x;
}
cameraResolution = getCameraResolution(parameters, screenResolutionForCamera);
}
示例13: onCreate
import android.view.Display; //导入依赖的package包/类
@Override
protected void onCreate(Bundle bundle, @NonNull MasterSecret masterSecret) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND,
WindowManager.LayoutParams.FLAG_DIM_BEHIND);
WindowManager.LayoutParams params = getWindow().getAttributes();
params.alpha = 1.0f;
params.dimAmount = 0.1f;
params.gravity = Gravity.TOP;
getWindow().setAttributes(params);
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
if (height > width) getWindow().setLayout((int) (width * .85), (int) (height * .5));
else getWindow().setLayout((int) (width * .7), (int) (height * .75));
super.onCreate(bundle, masterSecret);
titleView.setOnClickListener(null);
}
示例14: onCreate
import android.view.Display; //导入依赖的package包/类
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mSpinner = new ProgressDialog(getContext());
mSpinner.requestWindowFeature(Window.FEATURE_NO_TITLE);
mSpinner.setMessage("Loading...");
mContent = new LinearLayout(getContext());
mContent.setOrientation(LinearLayout.VERTICAL);
setUpTitle();
setUpWebView();
Display display = getWindow().getWindowManager().getDefaultDisplay();
final float scale = getContext().getResources().getDisplayMetrics().density;
float[] dimensions =
(display.getWidth() < display.getHeight()) ? DIMENSIONS_PORTRAIT : DIMENSIONS_LANDSCAPE;
addContentView(mContent, new FrameLayout.LayoutParams((int) (dimensions[0] * scale + 0.5f),
(int) (dimensions[1] * scale + 0.5f)));
CookieSyncManager.createInstance(getContext());
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeAllCookie();
}
示例15: onCreate
import android.view.Display; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
L.d("MotionClickService is create ");
DisplayMetrics dm = new DisplayMetrics();
Display mDisplay = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
mDisplay.getMetrics(dm);
deviceWidth = dm.widthPixels;
deviceHeight = dm.heightPixels;
initSocket();
EventBus.getDefault().register(this);
}