use of android.util.DisplayMetrics in project glitch-hq-android by tinyspeck.
the class BitmapUtil method ShowImage.
public static Bitmap ShowImage(String path, Activity act, ImageView imgv, int maxSize) {
if (maxSize <= 0) {
int nW = imgv.getWidth();
int nH = imgv.getHeight();
nW = Math.max(nW, nH);
if (nW == 0) {
DisplayMetrics metrics = GetScreenSize(act);
nW = Math.max(metrics.widthPixels, metrics.heightPixels);
}
maxSize = nW;
}
Bitmap bm = BitmapResampleFromStream(path, maxSize, maxSize);
imgv.setImageBitmap(bm);
return bm;
}
use of android.util.DisplayMetrics in project glitch-hq-android by tinyspeck.
the class BitmapUtil method GetScreenSize.
public static DisplayMetrics GetScreenSize(Activity act) {
DisplayMetrics metrics = new DisplayMetrics();
act.getWindowManager().getDefaultDisplay().getMetrics(metrics);
return metrics;
}
use of android.util.DisplayMetrics in project floatingsearchview by arimorty.
the class Util method getScreenWidth.
public static int getScreenWidth(Activity activity) {
Display display = activity.getWindowManager().getDefaultDisplay();
DisplayMetrics outMetrics = new DisplayMetrics();
display.getMetrics(outMetrics);
return outMetrics.widthPixels;
}
use of android.util.DisplayMetrics in project platform_frameworks_base by android.
the class UiDevice method getDisplaySizeDp.
/**
* Returns the display size in dp (device-independent pixel)
*
* The returned display size is adjusted per screen rotation. Also this will return the actual
* size of the screen, rather than adjusted per system decorations (like status bar).
*
* @return a Point containing the display size in dp
*/
public Point getDisplaySizeDp() {
Tracer.trace();
Display display = getAutomatorBridge().getDefaultDisplay();
Point p = new Point();
display.getRealSize(p);
DisplayMetrics metrics = new DisplayMetrics();
display.getRealMetrics(metrics);
float dpx = p.x / metrics.density;
float dpy = p.y / metrics.density;
p.x = Math.round(dpx);
p.y = Math.round(dpy);
return p;
}
use of android.util.DisplayMetrics in project platform_frameworks_base by android.
the class FrameworkActionBar method createMenuPopup.
/**
* Creates a Popup and adds it to the content frame. It also adds another {@link FrameLayout} to
* the content frame which shall serve as the new content root.
*/
@Override
public void createMenuPopup() {
if (!isOverflowPopupNeeded()) {
return;
}
DisplayMetrics metrics = mBridgeContext.getMetrics();
MenuBuilder menu = mActionBar.getMenuBuilder();
OverflowMenuAdapter adapter = new OverflowMenuAdapter(menu, mActionBar.getPopupContext());
ListView listView = new ListView(mActionBar.getPopupContext(), null, R.attr.dropDownListViewStyle);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(measureContentWidth(adapter), LayoutParams.WRAP_CONTENT);
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_END);
if (mActionBar.isSplit()) {
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
layoutParams.bottomMargin = getActionBarHeight() + mActionBar.getMenuPopupMargin();
} else {
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
layoutParams.topMargin = getActionBarHeight() + mActionBar.getMenuPopupMargin();
}
layoutParams.setMarginEnd(getPixelValue("5dp", metrics));
listView.setLayoutParams(layoutParams);
listView.setAdapter(adapter);
final TypedArray a = mActionBar.getPopupContext().obtainStyledAttributes(null, R.styleable.PopupWindow, R.attr.popupMenuStyle, 0);
listView.setBackground(a.getDrawable(R.styleable.PopupWindow_popupBackground));
listView.setDivider(a.getDrawable(R.attr.actionBarDivider));
a.recycle();
listView.setElevation(mActionBar.getMenuPopupElevation());
assert mEnclosingLayout != null : "Unable to find view to attach ActionMenuPopup.";
mEnclosingLayout.addView(listView);
}
Aggregations