protected static Point getDefaultWallpaperSize(Resources res, WindowManager windowManager) {
    if (sDefaultWallpaperSize == null) {
      Point minDims = new Point();
      Point maxDims = new Point();
      windowManager.getDefaultDisplay().getCurrentSizeRange(minDims, maxDims);

      int maxDim = Math.max(maxDims.x, maxDims.y);
      int minDim = Math.max(minDims.x, minDims.y);

      if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
        Point realSize = new Point();
        windowManager.getDefaultDisplay().getRealSize(realSize);
        maxDim = Math.max(realSize.x, realSize.y);
        minDim = Math.min(realSize.x, realSize.y);
      }

      // We need to ensure that there is enough extra space in the wallpaper
      // for the intended parallax effects
      final int defaultWidth, defaultHeight;
      if (isScreenLarge(res)) {
        defaultWidth = (int) (maxDim * wallpaperTravelToScreenWidthRatio(maxDim, minDim));
        defaultHeight = maxDim;
      } else {
        defaultWidth = Math.max((int) (minDim * WALLPAPER_SCREENS_SPAN), maxDim);
        defaultHeight = maxDim;
      }
      sDefaultWallpaperSize = new Point(defaultWidth, defaultHeight);
    }
    return sDefaultWallpaperSize;
  }
  @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
  public static Point getDefaultWallpaperSize(Resources res, WindowManager windowManager) {
    if (sDefaultWallpaperSize == null) {
      Point minDims = new Point();
      Point maxDims = new Point();
      windowManager.getDefaultDisplay().getCurrentSizeRange(minDims, maxDims);

      int maxDim = Math.max(maxDims.x, maxDims.y);
      int minDim = Math.max(minDims.x, minDims.y);

      if (Utilities.ATLEAST_JB_MR1) {
        Point realSize = new Point();
        windowManager.getDefaultDisplay().getRealSize(realSize);
        maxDim = Math.max(realSize.x, realSize.y);
        minDim = Math.min(realSize.x, realSize.y);
      }

      // We need to ensure that there is enough extra space in the wallpaper
      // for the intended parallax effects
      final int defaultWidth, defaultHeight;
      if (res.getConfiguration().smallestScreenWidthDp >= 720) {
        defaultWidth = (int) (maxDim * wallpaperTravelToScreenWidthRatio(maxDim, minDim));
        defaultHeight = maxDim;
      } else {
        defaultWidth = Math.max((int) (minDim * WALLPAPER_SCREENS_SPAN), maxDim);
        defaultHeight = maxDim;
      }
      sDefaultWallpaperSize = new Point(defaultWidth, defaultHeight);
    }
    return sDefaultWallpaperSize;
  }
Esempio n. 3
0
  /**
   * 处理大图片工具方法,避免 OOM
   *
   * @param imgPath : 图片路径
   * @return : 返回缩放后的图片
   */
  @SuppressWarnings("deprecation")
  public static Bitmap zoomBitmap(Activity activity, String imgPath) {
    //  1. 获取屏幕的宽高信息
    WindowManager windowManager = activity.getWindowManager();
    int width = windowManager.getDefaultDisplay().getWidth();
    int height = windowManager.getDefaultDisplay().getHeight();
    //      	System.out.println("屏幕的宽 = " + width + "   高 = " + height);

    //  2.获取图片的宽高
    Options options = new BitmapFactory.Options(); // 解析位图的附加条件
    options.inJustDecodeBounds = true; // 只解析位图的头文件信息(图片的附加信息)
    BitmapFactory.decodeFile(imgPath, options);
    int bitmapWidth = options.outWidth;
    int bitmapHeight = options.outHeight;
    //      	System.out.println("图片的宽 = " + bitmapWidth + "   高 = " + bitmapHeight);

    //  3.计算图片的缩放比例
    int dx = bitmapWidth / width;
    int dy = bitmapHeight / height;

    int scale = 1;
    if (dx > dy && dy > 1) {
      scale = dx;
      //          System.out.println("按照水平方向绽放,缩放比例 = " + dx);
    }
    if (dy > dx && dx > 1) {
      scale = dy;
      //          System.out.println("按照垂直方法缩放,缩放比例 = " + dy);
    }

    //  4.返回缩放后的位图给调用者
    options.inSampleSize = scale;
    options.inJustDecodeBounds = false; // 解析全部图片
    return BitmapFactory.decodeFile(imgPath, options);
  }
Esempio n. 4
0
  /**
   * Displays like a QuickAction from the anchor view.
   *
   * @param xOffset offset in the X direction
   * @param yOffset offset in the Y direction
   */
  public static void showLikeQuickAction(
      PopupWindow window,
      View root,
      View anchor,
      WindowManager windowManager,
      int xOffset,
      int yOffset) {

    window.setAnimationStyle(R.style.Animations_GrowFromBottomRight);

    int[] location = new int[2];
    anchor.getLocationOnScreen(location);

    Rect anchorRect =
        new Rect(
            location[0],
            location[1],
            location[0] + anchor.getWidth(),
            location[1] + anchor.getHeight());

    root.measure(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    int rootWidth = root.getMeasuredWidth();
    int rootHeight = root.getMeasuredHeight();

    int screenWidth = windowManager.getDefaultDisplay().getWidth();
    int screenHeight = windowManager.getDefaultDisplay().getHeight();

    int xPos = ((screenWidth - rootWidth) / 2) + xOffset;
    int yPos = anchorRect.top - rootHeight + yOffset;

    window.showAtLocation(anchor, Gravity.NO_GRAVITY, xPos, yPos);
  }
Esempio n. 5
0
 private void initAvatarSize() {
   WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
   Display display = windowManager.getDefaultDisplay();
   // 要获取屏幕的宽和高等参数,首先需要声明一个DisplayMetrics对象,屏幕的宽高等属性存放在这个对象中
   DisplayMetrics DM = new DisplayMetrics();
   // 获取窗口管理器,获取当前的窗口,调用getDefaultDisplay()后,其将关于屏幕的一些信息写进DM对象中,最后通过getMetrics(DM)获取
   windowManager.getDefaultDisplay().getMetrics(DM);
   displayWidth = DM.widthPixels;
   displayHeight = DM.heightPixels;
   // 使用display.getOrientation() 判断横竖屏不准确
   if (displayWidth > displayHeight) {
     displayWidth = DM.heightPixels;
     displayHeight = DM.widthPixels;
   }
   DisplayMetrics metrics = new DisplayMetrics();
   display.getMetrics(metrics);
   density = metrics.density;
   densityDpi = metrics.densityDpi;
   if (densityDpi <= DisplayMetrics.DENSITY_LOW) {
   } else if (densityDpi <= DisplayMetrics.DENSITY_MEDIUM) {
   } else if (densityDpi <= DisplayMetrics.DENSITY_HIGH
       && displayWidth <= Constants.DISPLAY_HDPI_WIDTH) {
   } else {
   }
   if (BuildConfig.DEBUG) {
     Log.v("Display Width: ", " " + displayWidth);
     Log.v("Display Height: ", " " + displayHeight);
     Log.v("Display Density: ", " " + densityDpi);
     Log.d(TAG, "initAvatarSize Finish : " + System.currentTimeMillis() / 1000);
   }
 }
Esempio n. 6
0
  /**
   * 鑾峰彇灞忓箷灏哄
   *
   * @param context
   * @return
   */
  public static int[] getScreenSize(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    int width = wm.getDefaultDisplay().getWidth();
    int height = wm.getDefaultDisplay().getHeight();
    int[] sizes = {width, height};

    return sizes;
  }
Esempio n. 7
0
 @Override
 public void onConfigurationChanged(Configuration newConfig) {
   // TODO Auto-generated method stub
   super.onConfigurationChanged(newConfig);
   WindowManager windowManager = getWindowManager();
   absolute_screen_width = windowManager.getDefaultDisplay().getWidth();
   absolute_screen_height = windowManager.getDefaultDisplay().getHeight();
 }
Esempio n. 8
0
 public static int getScreenHeight(Context context) {
   if (screenHeight == 0) {
     WindowManager mWindowManager =
         (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
     screenWidth = mWindowManager.getDefaultDisplay().getWidth();
     screenHeight = mWindowManager.getDefaultDisplay().getHeight();
   }
   return screenHeight;
 }
    /**
     * (非 Javadoc,覆写的方法) 
     * @Title: onCreate
     * @Description: 
     * @param savedInstanceState 
     * @see android.app.Dialog#onCreate(android.os.Bundle)
     */
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        WindowManager manager = getWindow().getWindowManager();
		int height = (int) (manager.getDefaultDisplay().getHeight() * 0.5f);
		int width = (int) (manager.getDefaultDisplay().getWidth() * 0.7f);
		ColorPickerView myView = new ColorPickerView(context, height, width);
        setContentView(myView);
        setTitle(title);
    }
Esempio n. 10
0
  @Override
  public void onMain() {

    mGiftScreen = new ArrayList<>();

    View view = this.inflate(R.layout.activity_main);
    this.getFrameLayout().addView(view);

    WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    final int mScreenWidth = windowManager.getDefaultDisplay().getWidth();
    final int mScreenHeight = windowManager.getDefaultDisplay().getHeight();

    this.initialization(mScreenWidth, mScreenHeight, true, LMode.Fill, false);

    ts = new GiftScreen(this, 5);
    //        LTexture lt = new LTexture("assets/gameover.png");
    //        ts.setBackground(lt);

    this.setScreen(ts);

    this.setDestroy(false); // 不强制关闭整个app

    //        this.setFPS(30);

    this.setShowFPS(true);

    this.setShowLogo(false);

    //        this.gameView().getView().setVisibility(View.GONE);

    //
    //        ((GLSurfaceView)this.gameView().getView()).setZOrderOnTop(true);
    //        ((GLSurfaceView)this.gameView().getView()).setEGLConfigChooser(8, 8, 8, 8, 16, 0);
    //
    // ((GLSurfaceView)this.gameView().getView()).getHolder().setFormat(PixelFormat.TRANSLUCENT);

    this.showScreen();
    Button btn = (Button) findViewById(R.id.main_test);
    btn.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            //                ts.setRunning(true);
            MainActivity.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            MainActivity.this
                .gameView()
                .getView()
                .setLayoutParams(new RelativeLayout.LayoutParams(mScreenHeight, mScreenWidth));
            maxScreen(mScreenHeight, mScreenWidth);
          }
        });

    //        ((TextView)this.findViewById(R.id.tv)).setText("hello");

  }
Esempio n. 11
0
 // 获取屏幕宽和高的方法
 public void getHeightAndWidth() {
   // 第一种获取屏幕宽高的方式
   WindowManager windowManager = getWindowManager();
   DisplayMetrics metrics = new DisplayMetrics();
   windowManager.getDefaultDisplay().getMetrics(metrics);
   int mScreenWidth1 = metrics.widthPixels;
   int mScreenHeight1 = metrics.heightPixels;
   // 第二种获取屏幕宽高的方式
   int mScreenWidth2 = windowManager.getDefaultDisplay().getWidth();
   int mScreenHeight2 = windowManager.getDefaultDisplay().getHeight();
 }
Esempio n. 12
0
  /**
   * Scrolls horizontally.
   *
   * @param side the side to which to scroll; {@link Side#RIGHT} or {@link Side#LEFT}
   * @param scrollPosition the position to scroll to, from 0 to 1 where 1 is all the way. Example
   *     is: 0.55.
   * @param stepCount how many move steps to include in the scroll. Less steps results in a faster
   *     scroll
   */
  @SuppressWarnings("deprecation")
  public void scrollToSide(Side side, float scrollPosition, int stepCount) {
    WindowManager windowManager =
        (WindowManager) inst.getTargetContext().getSystemService(Context.WINDOW_SERVICE);

    int screenHeight = windowManager.getDefaultDisplay().getHeight();
    int screenWidth = windowManager.getDefaultDisplay().getWidth();
    float x = screenWidth * scrollPosition;
    float y = screenHeight / 2.0f;
    if (side == Side.LEFT) drag(70, x, y, y, stepCount);
    else if (side == Side.RIGHT) drag(x, 0, y, y, stepCount);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);

    WindowManager vmManager = getActivity().getWindowManager();
    int width = vmManager.getDefaultDisplay().getWidth();
    int height = vmManager.getDefaultDisplay().getHeight();

    tabheight = (int) height * 1 / 12;

    Log.i(TAG, "---onCreate");
  }
Esempio n. 14
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.share_thought); // //键盘遮挡在Man中设置
    FileUtil.getInstance().makeDir(destDir);
    wm = this.getWindowManager();
    ScreenWidth = wm.getDefaultDisplay().getWidth();
    ScreenHeight = wm.getDefaultDisplay().getHeight();
    imageWidth = ScreenWidth / 3 - 60;
    imageHeight = imageWidth;
    list = new ArrayList<>();
    // 实例化GridView
    gridView = (GridView) findViewById(R.id.gridView_check_on);
    // 实例化EditText
    signText = (EditText) findViewById(R.id.share_thought_edit);
    /*
     * 实例化Button
     */
    // 提交按钮
    submitBt = (Button) findViewById(R.id.share_thought_share_bt);
    // 拍照按钮
    takePhotoBt = (ImageButton) findViewById(R.id.share_thought_camera);
    // 从本地获取图片按钮
    loadLocalPhotoBt = (ImageButton) findViewById(R.id.share_thought_load_local_photo);
    // 为按钮添加监听器
    submitBt.setOnClickListener(this);
    takePhotoBt.setOnClickListener(this);
    loadLocalPhotoBt.setOnClickListener(this);
    gridView.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Log.d("position", position + "");
            Intent intent = new Intent(ShareThought.this, ShowImageDetail.class);
            intent.putExtra(mark, position);
            startActivity(intent);
            overridePendingTransition(R.anim.activity_in, 0);
          }
        });

    gridView.setOnItemLongClickListener(
        new OnItemLongClickListener() {

          @Override
          public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            deletePosition = position;
            showDialog();
            return true;
          }
        });
  }
Esempio n. 15
0
 public PaintView(Context context, AttributeSet attrs) {
   super(context, attrs);
   this.context = context;
   mPaint = new Paint();
   mEraserPaint = new Paint();
   Init_Paint(UserInfo.PaintColor, UserInfo.PaintWidth);
   Init_Eraser(UserInfo.EraserWidth);
   WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
   width = manager.getDefaultDisplay().getWidth();
   height = manager.getDefaultDisplay().getHeight();
   mBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
   mCanvas = new Canvas(mBitmap);
   mPath = new Path();
   mBitmapPaint = new Paint(Paint.DITHER_FLAG);
 }
Esempio n. 16
0
  private void initVideoView() {
    mVideoWidth = 0;
    mVideoHeight = 0;
    getHolder().addCallback(mSHCallback);
    getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    setFocusable(true);
    setFocusableInTouchMode(true);
    requestFocus();
    mCurrentState = STATE_IDLE;
    mTargetState = STATE_IDLE;

    WindowManager windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    screenWidth = windowManager.getDefaultDisplay().getWidth();
    screenHeight = windowManager.getDefaultDisplay().getHeight();
  }
 public ImageGridAdapter(Context context, boolean showCamera, int column) {
   mContext = context;
   mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
   this.showCamera = showCamera;
   WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
   int width = 0;
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
     Point size = new Point();
     wm.getDefaultDisplay().getSize(size);
     width = size.x;
   } else {
     width = wm.getDefaultDisplay().getWidth();
   }
   mGridWidth = width / column;
 }
Esempio n. 18
0
  /** Prepare a dialog to show in the given {@link Context}. */
  public QuickContactWindow(Context context) {
    mContext = new ContextThemeWrapper(context, R.style.QuickContact);
    mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);

    mWindow = PolicyManager.makeNewWindow(mContext);
    mWindow.setCallback(this);
    mWindow.setWindowManager(mWindowManager, null, null);

    mWindow.setContentView(R.layout.quickcontact);

    mArrowUp = (ImageView) mWindow.findViewById(R.id.arrow_up);
    mArrowDown = (ImageView) mWindow.findViewById(R.id.arrow_down);

    mResolveCache = new ResolveCache(mContext);

    final Resources res = mContext.getResources();
    mShadowHoriz = res.getDimensionPixelSize(R.dimen.quickcontact_shadow_horiz);
    mShadowVert = res.getDimensionPixelSize(R.dimen.quickcontact_shadow_vert);
    mShadowTouch = res.getDimensionPixelSize(R.dimen.quickcontact_shadow_touch);

    mScreenWidth = mWindowManager.getDefaultDisplay().getWidth();
    mScreenHeight = mWindowManager.getDefaultDisplay().getHeight();

    mTrack = (ViewGroup) mWindow.findViewById(R.id.quickcontact);
    mTrackScroll = (HorizontalScrollView) mWindow.findViewById(R.id.scroll);

    mFooter = mWindow.findViewById(R.id.footer);
    mFooterDisambig = mWindow.findViewById(R.id.footer_disambig);
    mResolveList = (ListView) mWindow.findViewById(android.R.id.list);
    mSetPrimaryCheckBox = (CheckBox) mWindow.findViewById(android.R.id.checkbox);

    mSetPrimaryCheckBox.setOnCheckedChangeListener(this);

    // Prepare track entrance animation
    mTrackAnim = AnimationUtils.loadAnimation(mContext, R.anim.quickcontact);
    mTrackAnim.setInterpolator(
        new Interpolator() {
          public float getInterpolation(float t) {
            // Pushes past the target area, then snaps back into place.
            // Equation for graphing: 1.2-((x*1.6)-1.1)^2
            final float inner = (t * 1.55f) - 1.1f;
            return 1.2f - inner * inner;
          }
        });

    mHandler = new NotifyingAsyncQueryHandler(mContext, this);
  }
Esempio n. 19
0
 /**
  * 取得手机屏幕高度px
  *
  * @param context 上下文
  * @return 屏幕高度px
  */
 public static int getScreenHeightPx(Context context) {
   WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
   DisplayMetrics dm = new DisplayMetrics();
   manager.getDefaultDisplay().getMetrics(dm);
   int screenHeight = dm.heightPixels;
   return screenHeight;
 }
  // get real screen size
  private Point getRealScreenSize() {
    int heightPixels, widthPixels;
    Point screenResolution = null;
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display d = manager.getDefaultDisplay();
    DisplayMetrics metrics = new DisplayMetrics();
    d.getMetrics(metrics);
    // since SDK_INT = 1;
    heightPixels = metrics.heightPixels;
    widthPixels = metrics.widthPixels;
    // includes window decorations (statusbar bar/navigation bar)
    if (Build.VERSION.SDK_INT >= 14 && Build.VERSION.SDK_INT < 17)
      try {
        heightPixels = (Integer) Display.class.getMethod("getRawHeight").invoke(d);
        widthPixels = (Integer) Display.class.getMethod("getRawWidth").invoke(d);
      } catch (Exception ignored) {
      }
    // includes window decorations (statusbar bar/navigation bar)
    else if (Build.VERSION.SDK_INT >= 17)
      try {
        android.graphics.Point realSize = new android.graphics.Point();
        Display.class.getMethod("getRealSize", android.graphics.Point.class).invoke(d, realSize);
        heightPixels = realSize.y;
        widthPixels = realSize.x;
      } catch (Exception ignored) {

      }
    // Log.e("realHightPixels-heightPixels", heightPixels + "width");
    screenResolution = new Point(widthPixels, heightPixels);
    return screenResolution;
  }
Esempio n. 21
0
 @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
 void GetScreenSizeJB(Point size, boolean real) {
   WindowManager w = getWindowManager();
   if (real) {
     w.getDefaultDisplay().getRealSize(size);
   }
 }
Esempio n. 22
0
  @SuppressWarnings("deprecation")
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_scroll, container, false);
    ButterKnife.inject(this, rootView);

    initRollInformation(rootView);

    setOnclickListener();

    WindowManager wm = getActivity().getWindowManager();
    width = wm.getDefaultDisplay().getWidth();
    //        int leftMargin = width / 3;
    //        int caculateW = width - leftMargin;
    int dpW = ScreenUtil.dp2px(getActivity(), 100);

    int _width = (width - dpW) / mRow;

    // If we do this we need to uncomment the container on the xml layout
    createListBuddiesLayoutDinamically(rootView);
    // mImagesLeft.addAll(Arrays.asList(ImagesUrls.imageUrls_left));
    // mImagesRight.addAll(Arrays.asList(ImagesUrls.imageUrls_right));
    initData(_width);
    //		mListBuddies.setOnItemClickListener(this);
    return rootView;
  }
Esempio n. 23
0
 public static int px2dip(Context ctx, int pxValue) {
   WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
   DisplayMetrics metrics = new DisplayMetrics();
   wm.getDefaultDisplay().getMetrics(metrics);
   float scale = metrics.density;
   return (int) (pxValue / scale + 0.5f);
 }
Esempio n. 24
0
  // create a new ImageView for each item referenced by the Adapter
  public View getView(int position, View convertView, ViewGroup parent) {
    ImageView imageView;
    if (convertView == null) {
      // if it's not recycled, initialize some attributes
      imageView = new ImageView(mContext);
      WindowManager wm =
          (WindowManager) parent.getContext().getSystemService(Context.WINDOW_SERVICE);
      Display display = wm.getDefaultDisplay();
      Point size = new Point();
      display.getSize(size);
      int width = size.x;
      if (width < 1080) {
        imageView.setLayoutParams(new GridView.LayoutParams(250, 180));
      } else {
        imageView.setLayoutParams(new GridView.LayoutParams(350, 250));
      }
      imageView.setScaleType(ImageView.ScaleType.FIT_XY);
      imageView.setPadding(8, 8, 8, 8);
    } else {
      imageView = (ImageView) convertView;
    }

    imageView.setImageResource(mThumbIds[position]);
    return imageView;
  }
Esempio n. 25
0
 public static int getDisplayWidth(Context context) {
   DisplayMetrics displayMetrics = new DisplayMetrics();
   WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
   wm.getDefaultDisplay().getMetrics(displayMetrics);
   int displayWidth = displayMetrics.widthPixels;
   return displayWidth;
 }
Esempio n. 26
0
 private void setViewSize() {
   WindowManager m = getWindowManager();
   Display d = m.getDefaultDisplay();
   ViewGroup.LayoutParams params = previewImage.getLayoutParams();
   params.height = (int) (d.getHeight() * 0.3);
   previewImage.setLayoutParams(params);
 }
Esempio n. 27
0
  @Override
  protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);
    sHeight = getHeight();
    sWidth = getWidth();
    if (sHeight == 0 || sWidth == 0) {
      android.util.DisplayMetrics mMetrics = new android.util.DisplayMetrics();
      android.view.WindowManager wm =
          (android.view.WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
      wm.getDefaultDisplay().getMetrics(mMetrics);
      sHeight = mMetrics.heightPixels;
      sWidth = mMetrics.widthPixels;
    }

    if (sHeight < sWidth) {
      texY = 0;
      texX = (sWidth - sHeight) / 2;
      ;
      texWidth = sHeight;
    } else {
      texY = (sHeight - sWidth) / 2;
      texX = 0;
      texWidth = sWidth;
    }

    mBitmapViewWidth = (int) (sWidth / 2);
    mCenterX = mBitmapViewWidth;
    mCenterY = sHeight / 2;
    mScreenRadius = Math.min(mBitmapViewWidth, sHeight / 2);
    // mBitmap.getHeight()));
    setDrawingCacheBackgroundColor(Color.TRANSPARENT);
    setBitmap();
    drawIntoBitmap();
  }
Esempio n. 28
0
 // 获取屏幕的分辨率
 private void getViewSize(Context context) {
   DisplayMetrics metrics = new DisplayMetrics();
   WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
   windowManager.getDefaultDisplay().getMetrics(metrics);
   this.screenHeight = metrics.heightPixels;
   this.screenWidth = metrics.widthPixels;
 }
Esempio n. 29
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.edit_post_layout);

    WindowManager mWm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    mWm.getDefaultDisplay().getMetrics(dm);

    /*TextView textview_city = (TextView)findViewById(R.id.textcity_item);
    LayoutParams laParams0 = (LayoutParams)textview_city.getLayoutParams();
    laParams0.height=dm.heightPixels - dm.widthPixels;
    laParams0.width = dm.widthPixels;
    textview_city.setPadding(0, 0, 100, 200);*/
    // textview_city.setLayoutParams(laParams0);

    // ����mContext

    mPoscalCodList = new ArrayList<String>();

    // ��ȡ���
    readPostalCodeList();

    mCheckArray = new boolean[mPoscalCodList.size()];
    for (int i = 0; i < mCheckArray.length; i++) {
      mCheckArray[i] = false;
    }

    mgridview = (GridView) findViewById(R.id.grid_citys);
    mgridview.requestFocus();
    mcitysAdapter = new citysAdapter(this);
    mgridview.setAdapter(mcitysAdapter);

    WeatherReceiver.setEditHandler(mHandler);
  }
Esempio n. 30
0
 public static RectI getDeviceScreenSize(Context context, boolean useDeviceSize) {
   RectI rect = new RectI();
   WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
   android.view.Display display = windowManager.getDefaultDisplay();
   DisplayMetrics metrics = new DisplayMetrics();
   display.getMetrics(metrics);
   int widthPixels = metrics.widthPixels;
   int heightPixels = metrics.heightPixels;
   if (!useDeviceSize) {
     rect.width = widthPixels;
     rect.height = heightPixels;
     return rect;
   }
   int buildInt = AndroidGame.getSDKVersion();
   if (buildInt >= 14 && buildInt < 17)
     try {
       widthPixels = (Integer) android.view.Display.class.getMethod("getRawWidth").invoke(display);
       heightPixels =
           (Integer) android.view.Display.class.getMethod("getRawHeight").invoke(display);
     } catch (Exception ignored) {
     }
   if (buildInt >= 17)
     try {
       android.graphics.Point realSize = new android.graphics.Point();
       android.view.Display.class
           .getMethod("getRealSize", android.graphics.Point.class)
           .invoke(display, realSize);
       widthPixels = realSize.x;
       heightPixels = realSize.y;
     } catch (Exception ignored) {
     }
   rect.width = widthPixels;
   rect.height = heightPixels;
   return rect;
 }