Search in sources :

Example 11 with DisplayMetrics

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;
}
Also used : Bitmap(android.graphics.Bitmap) DisplayMetrics(android.util.DisplayMetrics) Paint(android.graphics.Paint)

Example 12 with DisplayMetrics

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;
}
Also used : DisplayMetrics(android.util.DisplayMetrics)

Example 13 with DisplayMetrics

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;
}
Also used : DisplayMetrics(android.util.DisplayMetrics) Display(android.view.Display)

Example 14 with DisplayMetrics

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;
}
Also used : Point(android.graphics.Point) DisplayMetrics(android.util.DisplayMetrics) Display(android.view.Display)

Example 15 with DisplayMetrics

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);
}
Also used : ListView(android.widget.ListView) LayoutParams(android.view.ViewGroup.LayoutParams) TypedArray(android.content.res.TypedArray) RelativeLayout(android.widget.RelativeLayout) DisplayMetrics(android.util.DisplayMetrics) MenuBuilder(com.android.internal.view.menu.MenuBuilder)

Aggregations

DisplayMetrics (android.util.DisplayMetrics)772 WindowManager (android.view.WindowManager)107 Resources (android.content.res.Resources)99 Display (android.view.Display)78 Configuration (android.content.res.Configuration)61 Point (android.graphics.Point)57 View (android.view.View)52 SuppressLint (android.annotation.SuppressLint)47 Bitmap (android.graphics.Bitmap)42 Paint (android.graphics.Paint)42 Activity (android.app.Activity)32 ImageView (android.widget.ImageView)27 AssetManager (android.content.res.AssetManager)25 TypedArray (android.content.res.TypedArray)25 Context (android.content.Context)23 TypedValue (android.util.TypedValue)23 ViewGroup (android.view.ViewGroup)23 TextView (android.widget.TextView)22 Intent (android.content.Intent)21 RelativeLayout (android.widget.RelativeLayout)20