當前位置: 首頁>>代碼示例>>Java>>正文


Java Display類代碼示例

本文整理匯總了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)));
    }
}
 
開發者ID:StylingAndroid,項目名稱:PresenterLite,代碼行數:21,代碼來源:DisplayInfoHelper.java

示例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);

}
 
開發者ID:vitaviva,項目名稱:QRCodeScanner,代碼行數:20,代碼來源:BarcodeScanView.java

示例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;
        }
    }
}
 
開發者ID:l465659833,項目名稱:Bigbang,代碼行數:19,代碼來源:ViewUtil.java

示例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();
}
 
開發者ID:NullPointersInc,項目名稱:Bella-Android,代碼行數:12,代碼來源:MainActivity.java

示例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);
    }
}
 
開發者ID:NeoTerm,項目名稱:NeoTerm,代碼行數:21,代碼來源:MainActivity.java

示例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();
    }
}
 
開發者ID:chengzichen,項目名稱:KrGallery,代碼行數:22,代碼來源:AndroidUtilities.java

示例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);
    }
}
 
開發者ID:gigabytedevelopers,項目名稱:CalcMate,代碼行數:17,代碼來源:Calculator.java

示例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);
}
 
開發者ID:AnyRTC,項目名稱:anyRTC-RTCP-Android,代碼行數:25,代碼來源:CameraConfigurationManager.java

示例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);
}
 
開發者ID:monsieurh,項目名稱:homebank_android,代碼行數:22,代碼來源:AppStoreInterstitial.java

示例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));
        }
    
    }
 
開發者ID:sfilmak,項目名稱:MakiLite,代碼行數:26,代碼來源:QuickTwitter.java

示例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;
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:19,代碼來源:ShareDialogBuilder.java

示例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);

}
 
開發者ID:RuanXiaoHui,項目名稱:ZxingScan,代碼行數:24,代碼來源:CameraConfigurationManager.java

示例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);
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:23,代碼來源:ConversationPopupActivity.java

示例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();
}
 
開發者ID:mukeshsolanki,項目名稱:social-login-helper,代碼行數:20,代碼來源:InstagramDialog.java

示例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);
}
 
開發者ID:kaixuanluo,項目名稱:pc-android-controller-android,代碼行數:17,代碼來源:MotionClickService.java


注:本文中的android.view.Display類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。