Example usage for android.util TypedValue COMPLEX_UNIT_DIP

List of usage examples for android.util TypedValue COMPLEX_UNIT_DIP

Introduction

In this page you can find the example usage for android.util TypedValue COMPLEX_UNIT_DIP.

Prototype

int COMPLEX_UNIT_DIP

To view the source code for android.util TypedValue COMPLEX_UNIT_DIP.

Click Source Link

Document

#TYPE_DIMENSION complex unit: Value is Device Independent Pixels.

Usage

From source file:com.android.switchaccess.OptionManager.java

@Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
    Context context = mOverlayController.getContext();
    mOptionScanningEnabled = SwitchAccessPreferenceActivity.isOptionScanningEnabled(context);
    String defaultWeight = context.getString(R.string.pref_highlight_weight_default);
    /* Configure highlighting */
    for (int i = 0; i < mOptionPaintArray.length; ++i) {
        /*/*from ww w . ja v a2  s .  c  o m*/
         * Always configure element 0 based on preferences. Only configure the others if we're
         * option scanning.
         */
        if ((i == 0) || mOptionScanningEnabled) {
            String hexStringColor = prefs.getString(mHighlightColorPrefKeys[i], mHighlightColorDefaults[i]);
            int color = Integer.parseInt(hexStringColor, 16);
            mOptionPaintArray[i].setColor(color);
            mOptionPaintArray[i].setAlpha(255);

            String stringWeight = prefs.getString(mHighlightWeightPrefKeys[i], defaultWeight);
            int weight = Integer.valueOf(stringWeight);
            DisplayMetrics dm = context.getResources().getDisplayMetrics();
            float strokeWidth = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, weight, dm);
            mOptionPaintArray[i].setStrokeWidth(strokeWidth);
        } else {
            mOptionPaintArray[i].setColor(Color.TRANSPARENT);
        }
    }
    mStartScanAutomatically = prefs.getBoolean(context.getString(R.string.switch_access_auto_start_scan_key),
            false);
}

From source file:com.yamin.kk.vlc.Util.java

public static int convertDpToPx(int dp) {
    return Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp,
            VLCApplication.getAppResources().getDisplayMetrics()));
}

From source file:com.bwash.bwashcar.view.PagerSlidingTabStrip.java

private void updateTabStyles() {

    for (int i = 0; i < tabCount; i++) {

        View v = tabsContainer.getChildAt(i);
        if (pager.getAdapter() instanceof IconTabProvider) {
            TextView tab = (TextView) v.findViewById(R.id.text);
            tab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(((IconTabProvider) pager.getAdapter()).getPageTextColor(i));
            tab.setCompoundDrawablesWithIntrinsicBounds(
                    getResources().getDrawable(((IconTabProvider) pager.getAdapter()).getPageIconResId(i)),
                    null, null, null);/*w  ww .  j a  v  a  2  s.c om*/
            //            tab.setBackgroundDrawable(getResources().getDrawable(((IconTabProvider)pager.getAdapter()).getPageIconResId(i)));
            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }
            }
        } else {
            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(0xffffffff);
            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }
            }
        }
    }

}

From source file:com.cube.storm.ui.view.PagerSlidingTabStrip.java

private void addIconTab(final int position, Bitmap bitmap) {
    ImageView tab = new ImageView(getContext());
    tab.setImageBitmap(bitmap);//from w  w  w .j a  va  2 s. c  o  m
    tab.setColorFilter(tabIconTint);
    tab.setScaleType(ScaleType.FIT_CENTER);

    DisplayMetrics dm = getResources().getDisplayMetrics();
    int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, dm);

    tab.setPadding(padding + tabPadding, padding, padding + tabPadding, padding);

    tab.setFocusable(true);
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(android.view.View v) {
            pager.setCurrentItem(position);
        }
    });

    tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
}

From source file:com.example.fan.horizontalscrollview.PagerSlidingTabStrip.java

public TextView getTextTab(final int position, String title) {

    TextView tab = new TextView(getContext());
    tab.setText(title);//from w  ww.jav  a 2  s  .  co  m
    tab.setFocusable(true);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    tab.setTextColor(getResources().getColorStateList(
            mTextChangeable ? R.color.pst_tab_changeable_text_selector : R.color.pst_tab_text_selector));
    tab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18.0f);
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (null != mOnPageClickedLisener) {
                mOnPageClickedLisener.onPageClicked(position);
            }
            pager.setCurrentItem(position);
        }
    });

    return tab;
}

From source file:cf.obsessiveorange.rhcareerfairlayout.ui.fragments.VPParentFragment.java

/**
 * Private helper method to animate toolbar and related views to a position.
 * @param toY New Y position./* w  w  w  .  jav a 2s . c  om*/
 * @param completionHandlers any handlers to be fired after completion of the animation
 */
private void animateToolbar(final float toY, final Runnable... completionHandlers) {
    float layoutTranslationY = mInterceptionLayout.getTranslationY();
    if (layoutTranslationY != toY) {
        // get translation
        final float translationY = -layoutTranslationY + toY;

        final View toolbarView = getActivity().findViewById(R.id.toolbar);
        final SearchBox searchView = ((MainActivity) getActivity()).getSearch();

        // Need to offset for the -6dp margin on search bar
        Resources r = getResources();
        float offset = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 6, r.getDisplayMetrics());

        // Start animating all the items
        mInterceptionLayout.animate().y(toY).setDuration(200);
        toolbarView.animate().y(toY).setDuration(200);
        searchView.animate().y(toY - offset).setDuration(200);

        // Relayout child view at animation completion
        final FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mInterceptionLayout.getLayoutParams();
        new Handler().postDelayed(new Runnable() {
            public void run() {
                lp.height = (int) (Math.max(0, -translationY) + getScreenHeight());
                mInterceptionLayout.requestLayout();
            }
        }, translationY < 0 ? 0 : 200);

        // Start calling all handlers, giving time for re-layout to occur.
        new Handler().postDelayed(new Runnable() {
            public void run() {
                for (Runnable completionHandler : completionHandlers) {
                    completionHandler.run();
                }
            }
        }, 250);

    }
}

From source file:com.polyvi.xface.extension.inappbrowser.XInAppBrowser.java

/**
 * DIP?//from  w  w  w . j  a  v a2s  .  c om
 *
 * @param dipValue
 *            dip
 * @return int
 */
protected int dpToPixels(int dipValue) {
    int value = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) dipValue,
            mContext.getResources().getDisplayMetrics());

    return value;
}

From source file:com.example.view.astuetz.PagerSlidingTabStrip.java

@SuppressLint("NewApi")
private void addIconTab(int position, int resId, String notification) {
    FrameLayout tabItemCon = new FrameLayout(getContext());
    ImageView tab = new ImageView(getContext());
    tab.setImageResource(resId);/*from w w  w. j  a va  2s  .  c o  m*/
    tabItemCon.addView(tab);
    tabIconlist.put(position, tab);
    ImageView notiSymbol = new ImageView(getContext());
    notiSymbol.setImageResource(R.drawable.badge_background);
    BadgeView noti = new BadgeView(getContext());
    noti.setText(notification);
    tabItemCon.addView(noti);
    tabItemCon.addView(notiSymbol);
    if (notification != null && !notification.equals("")) {
        noti.setVisibility(View.VISIBLE);
        notiSymbol.setVisibility(View.GONE);
    } else if (notification != null && notification.equals("")) {
        noti.setVisibility(View.GONE);
        notiSymbol.setVisibility(View.VISIBLE);
    } else {
        notiSymbol.setVisibility(View.GONE);
        noti.setVisibility(View.GONE);
    }
    int notiSySize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20,
            getResources().getDisplayMetrics());
    noti.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
            Gravity.RIGHT | Gravity.TOP));
    notiSymbol.setLayoutParams(new LayoutParams(notiSySize, notiSySize, Gravity.RIGHT | Gravity.TOP));
    FrameLayout tabItem = new FrameLayout(getContext());
    tabItem.addView(tabItemCon);
    tabItemCon.setLayoutParams(
            new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER));
    addTab(position, tabItem);
}

From source file:com.example.mapsv2.ClustersAreListsActivity.java

private void setupPart2() {
    fullScreenOverlay = findViewById(R.id.fullscreen_overlay);
    // Set the full screen overlay to be invisible but not GONE initially
    // because otherwise it's won't get width/height set in a layout pass
    fullScreenOverlay.setVisibility(View.INVISIBLE);
    fullScreenOverlay.setOnClickListener(new View.OnClickListener() {
        @Override/*w w w. ja v a  2s. c om*/
        public void onClick(View v) {
            hideInfoWindow();
        }
    });

    listView = (ListView) findViewById(android.R.id.list);
    listView.setAdapter(
            new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, new LinkedList<String>()));
    // infowindow is the parent of the ListView and we'll position it to
    // appear to "point at" the selected map marker
    infoWindow = findViewById(R.id.info_window);
    // All our markers are the same width & height and are scaled exactly
    // for each density. YMMV.
    markerSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32,
            getResources().getDisplayMetrics());
    defaultMargin = getResources().getDimensionPixelOffset(R.dimen.activity_horizontal_margin);
}

From source file:mp.paschalis.App.java

public static void setStyleErrorDirection(TextView pTextView) {
    pTextView.setTextColor(Color.parseColor("#C2022C"));
    pTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 25);

}