Example usage for android.view WindowManager getDefaultDisplay

List of usage examples for android.view WindowManager getDefaultDisplay

Introduction

In this page you can find the example usage for android.view WindowManager getDefaultDisplay.

Prototype

public Display getDefaultDisplay();

Source Link

Document

Returns the Display upon which this WindowManager instance will create new windows.

Usage

From source file:com.plusub.lib.example.view.TabView.java

private void init(Context context) {
    tabItemList = new ArrayList<TabHolder>();
    DisplayMetrics metric = new DisplayMetrics();
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    wm.getDefaultDisplay().getMetrics(metric);
    mScreenWidth = metric.widthPixels;/*from  w  w  w  . j av  a2s. com*/
    mInflater = LayoutInflater.from(context);
    mTabView = (LinearLayout) mInflater.inflate(R.layout.view_tab_layout, null);
    LinearLayout.LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, ImageUtils.Dp2Px(context, 40));
    lp.gravity = Gravity.CENTER;
    mTabView.setLayoutParams(lp);
    addView(mTabView, new LinearLayout.LayoutParams(0, MATCH_PARENT, 1));
    initViews();
}

From source file:com.harmazing.aixiumama.activity.ActivityGallery.java

private Bitmap GetandSaveCurrentImage() {
    //Bitmap/*from w  w w  .  ja v  a 2s .  c  o m*/
    WindowManager windowManager = getWindowManager();
    Display display = windowManager.getDefaultDisplay();
    int w = display.getWidth();
    int h = display.getHeight();
    Bitmap Bmp = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565);
    //??
    View decorview = this.getWindow().getDecorView();
    //        decorview.setDrawingCacheEnabled(true);
    //        decorview.buildDrawingCache();
    //        Bmp = decorview.getDrawingCache();
    Canvas c = new Canvas(Bmp);
    decorview.draw(c);
    // 
    Bmp = Bitmap.createBitmap(Bmp, 0, BitmapUtil.dip2px(getApplicationContext(), 50) + getTopViewHeight(), w,
            CuteApplication.getScreenHW(getApplicationContext())[0]
                    - BitmapUtil.dip2px(getApplicationContext(), 10));

    decorview.destroyDrawingCache();
    decorview.setDrawingCacheEnabled(false);
    return Bmp;
}

From source file:com.breadwallet.BreadWalletApp.java

@Override
public void onCreate() {
    super.onCreate();

    WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);//from w w  w.  ja  v a  2  s  . co  m
    int DISPLAY_WIDTH_PX = size.x;
    DISPLAY_HEIGHT_PX = size.y;
    mFingerprintManager = (FingerprintManager) getSystemService(Context.FINGERPRINT_SERVICE);

}

From source file:com.tomandfelix.stapp2.tabs.SlidingTabLayout.java

public void setLabelWidth() {
    WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);/*www. j av a 2s . c o m*/
    for (TextView t : labels) {
        t.setWidth(size.x / 2);
    }
}

From source file:com.appsimobile.appsii.HotspotHelperImpl.java

@Override
public void setSwipeLocation(SidebarHotspot hotspot, int localX, int localY, int rawX, int rawY) {
    WindowManager wm = mWindowManager;
    Display display = wm.getDefaultDisplay();
    int width = display.getWidth();
    if (mDraggingHotspot) {
        boolean left = rawX < width / 2;
        int deltaY = mRawStartDragY - rawY;
        setSwipeLocationForHotspotDrag(hotspot, localX, deltaY, left);
    }/*www  .jav a2  s.  co  m*/
}

From source file:com.byteridge.bookcircle.ui.TabPageIndicator.java

private void addTab(CharSequence text, int index) {
    // text = "Tab " + index;
    final TabView tabView = new TabView(getContext());
    tabView.mIndex = index;// w  ww .  jav a  2  s  .c o  m
    tabView.setFocusable(true);
    tabView.setOnClickListener(mTabClickListener);
    tabView.setText(text);
    WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
    DisplayMetrics displaymetrics = new DisplayMetrics();
    wm.getDefaultDisplay().getMetrics(displaymetrics);
    int width = displaymetrics.widthPixels;
    tabView.setWidth(width / 3);
    tabView.setTextColor(Color.BLACK);
    tabView.setTextSize(13);
    // tabView.setShadowLayer(1, 1, 1, Color.WHITE);
    // tabView.setTypeface(GreatBuyzApplication.getApplication().getFont()); // ,Typeface.BOLD);
    tabView.setLayoutParams(
            new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f));
    mTabLayout.addView(tabView, new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f));
}

From source file:com.teamunemployment.breadcrumbs.client.view.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.//  www .  j ava2 s  . c  o  m
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    textView.setWidth(size.x / 3);

    return textView;
}

From source file:client.smrtms.com.smrtms_client.View.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.//from   www. j a  va 2s.c o m
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    textView.setWidth(size.x / 3);

    return textView;
}

From source file:com.rizomm.ram.libeery.commonViews.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}./*from  w w w .j  a va  2s.c om*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    textView.setWidth(size.x / 2);

    return textView;
}

From source file:com.example.fabian.matchit.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}./* w w w  .  j  a  v a 2s  .  c o  m*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    //textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setTextColor(getResources().getColor(R.color.white));

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);
    // Text evenredig verdelen
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    textView.setWidth(size.x / 3);

    return textView;
}