List of usage examples for android.util TypedValue applyDimension
public static float applyDimension(int unit, float value, DisplayMetrics metrics)
From source file:com.daiv.android.twitter.ui.drawer_activities.DrawerActivity.java
public int toDP(int px) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, px, getResources().getDisplayMetrics()); }
From source file:com.daiv.android.twitter.ui.compose.Compose.java
public int toDP(int px) { try {/* ww w . j av a 2 s .c o m*/ return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, px, getResources().getDisplayMetrics()); } catch (Exception e) { return px; } }
From source file:com.dragon4.owo.ar_trace.ARCore.MixView.java
public void initNaverMap() { naverFragment = new FragmentMapview(); naverFragment.setArguments(new Bundle()); final Button expandView = (Button) mainArView.findViewById(R.id.ar_mixview_naverview_expand); expandView.setOnClickListener(new View.OnClickListener() { boolean isFull = false; @Override// w w w.jav a 2 s .c om public void onClick(View view) { RelativeLayout navermapWrapper = (RelativeLayout) mainArView .findViewById(R.id.ar_mixview_naverview_wrapper); if (isFull) { RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, naver_map_width, Resources.getSystem().getDisplayMetrics()), (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, naver_map_height, Resources.getSystem().getDisplayMetrics())); int tenMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, Resources.getSystem().getDisplayMetrics()); params.setMargins(0, tenMargin, tenMargin, 0); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); params.addRule(RelativeLayout.ALIGN_PARENT_TOP); navermapWrapper.setLayoutParams(params); expandView.setBackgroundResource(R.drawable.ic_minimap_zoom_in); isFull = false; } else { RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); params.setMargins(0, 0, 0, 0); navermapWrapper.setLayoutParams(params); expandView.setBackgroundResource(R.drawable.ic_minimap_zoom_out); isFull = true; } } }); try { FragmentTransaction fragmentTransaction = ((FragmentActivity) context).getSupportFragmentManager() .beginTransaction(); fragmentTransaction.add(R.id.ar_mixview_naverview, naverFragment); fragmentTransaction.commit(); } catch (Exception e) { e.printStackTrace(); Log.i(TAG, "Only FragmentActivity can use naver maps"); } }
From source file:com.codename1.impl.android.AndroidImplementation.java
public int translatePixelForDPI(int pixel) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, pixel, getContext().getResources().getDisplayMetrics()); }
From source file:com.android.mail.browse.ConversationItemView.java
private boolean isTouchInContactPhoto(float x, float y) { // Everything before the end edge of contact photo final boolean isRtl = ViewUtils.isViewRtl(this); final int threshold = (isRtl) ? mCoordinates.contactImagesX - sSenderImageTouchSlop : mCoordinates.contactImagesX + mCoordinates.contactImagesWidth + sSenderImageTouchSlop; // Allow touching a little right of the contact photo when we're already in selection mode final float extra; if (mCheckedConversationSet == null || mCheckedConversationSet.isEmpty()) { extra = 0;//from w w w. j ava 2 s . c om } else { extra = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, getResources().getDisplayMetrics()); } return mHeader.gadgetMode == ConversationItemViewCoordinates.GADGET_CONTACT_PHOTO && ((isRtl) ? x > (threshold - extra) : x < (threshold + extra)); }
From source file:com.if3games.chessonline.DroidFish.java
private final void updateButtons() { boolean largeButtons = settings.getBoolean("largeButtons", false); Resources r = getResources(); int bWidth = (int) Math .round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 36, r.getDisplayMetrics())); int bHeight = (int) Math .round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32, r.getDisplayMetrics())); if (largeButtons) { if (custom1ButtonActions.isEnabled() && custom2ButtonActions.isEnabled() && custom3ButtonActions.isEnabled()) { Configuration config = getResources().getConfiguration(); if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) { bWidth = bWidth * 6 / 5; bHeight = bHeight * 6 / 5; } else { bWidth = bWidth * 5 / 4; bHeight = bHeight * 5 / 4; }/*from w w w . j a v a 2 s . com*/ } else { bWidth = bWidth * 3 / 2; bHeight = bHeight * 3 / 2; } } SVG svg = SVGParser.getSVGFromResource(getResources(), R.raw.touch); setButtonData(custom1Button, bWidth, bHeight, custom1ButtonActions.getIcon(), svg); setButtonData(custom2Button, bWidth, bHeight, custom2ButtonActions.getIcon(), svg); setButtonData(custom3Button, bWidth, bHeight, custom3ButtonActions.getIcon(), svg); setButtonData(modeButton, bWidth, bHeight, R.raw.mode, svg); setButtonData(undoButton, bWidth, bHeight, R.raw.left, svg); setButtonData(redoButton, bWidth, bHeight, R.raw.right, svg); }
From source file:com.albedinsky.android.ui.widget.SeekBarWidget.java
/** * Sets a size for the discrete indicator's text to the given <var>unit</var> and <var>size</var>. * * @param unit The desired dimension unit. See {@link TypedValue} for possible units. * @param size The desired size in the specified unit. * @see #setDiscreteIndicatorTextSize(float) * @see #getDiscreteIndicatorTextSize()/*from w w w . j a va2s .c o m*/ */ public void setDiscreteIndicatorTextSize(int unit, float size) { setDiscreteIndicatorRawTextSize(TypedValue.applyDimension(unit, size, getResources().getDisplayMetrics())); }
From source file:edu.mit.viral.shen.DroidFish.java
private final void updateButtons() { boolean largeButtons = settings.getBoolean("largeButtons", true); Resources r = getResources(); int bWidth = (int) Math .round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 36, r.getDisplayMetrics())); int bHeight = (int) Math .round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32, r.getDisplayMetrics())); if (largeButtons) { if (custom1ButtonActions.isEnabled() && custom2ButtonActions.isEnabled() && custom3ButtonActions.isEnabled()) { Configuration config = getResources().getConfiguration(); if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) { bWidth = bWidth * 7 / 6; bHeight = bHeight * 7 / 6; } else { bWidth = bWidth * 6 / 5; bHeight = bHeight * 6 / 5; }/* ww w. j a v a2 s. c o m*/ } else { bWidth = bWidth * 3 / 2; bHeight = bHeight * 3 / 2; } } SVG svg = SVGParser.getSVGFromResource(getResources(), R.raw.touch); setButtonData(custom1Button, bWidth, bHeight, custom1ButtonActions.getIcon(), svg); setButtonData(custom2Button, bWidth, bHeight, custom2ButtonActions.getIcon(), svg); setButtonData(custom3Button, bWidth, bHeight, custom3ButtonActions.getIcon(), svg); setButtonData(commentButton, bWidth, bHeight, R.raw.comment, svg); setButtonData(undoButton, bWidth, bHeight, R.raw.left, svg); setButtonData(redoButton, bWidth, bHeight, R.raw.right, svg); }
From source file:com.hichinaschool.flashcards.anki.Reviewer.java
private void setInterface() { if (mCurrentCard == null) { return;//w ww . ja v a2 s .c o m } if (mSimpleInterface) { Note note = mCurrentCard.note(); mCurrentSimpleInterface = true; for (String s : mSimpleInterfaceExcludeTags) { if (note.hasTag(s)) { mCurrentSimpleInterface = false; break; } } } if (mCurrentSimpleInterface) { if (mSimpleCard == null) { mSimpleCard = new ScrollTextView(this); Themes.setRegularFont(mSimpleCard); mSimpleCard.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, getResources().getDisplayMetrics()) * mDisplayFontSize / 100); mSimpleCard.setGravity(Gravity.CENTER); try { mSetTextIsSelectable = TextView.class.getMethod("setTextIsSelectable", boolean.class); } catch (Throwable e) { // Log.i(AnkiDroidApp.TAG, "mSetTextIsSelectable could not be found due to a too low Android version (< 3.0)"); mSetTextIsSelectable = null; } if (mSetTextIsSelectable != null) { try { mSetTextIsSelectable.invoke(mSimpleCard, true); } catch (Exception e) { Log.e(AnkiDroidApp.TAG, e.toString()); } } mSimpleCard.setClickable(true); mCardFrame.addView(mSimpleCard); mSimpleCard.setBackgroundColor(mCurrentBackgroundColor); mSimpleCard.setTextColor(mForegroundColor); } if (mSimpleCard.getVisibility() != View.VISIBLE || (mCard != null && mCard.getVisibility() == View.VISIBLE)) { mSimpleCard.setVisibility(View.VISIBLE); mCard.setVisibility(View.GONE); } } else { if (mCard == null) { mCard = createWebView(); mCardFrame.addView(mCard); if (!mUseQuickUpdate) { mNextCard = createWebView(); mNextCard.setVisibility(View.GONE); mCardFrame.addView(mNextCard, 0); mCard.setBackgroundColor(mCurrentBackgroundColor); mCustomFontStyle = getCustomFontsStyle() + getDefaultFontStyle(); } } if (mCard.getVisibility() != View.VISIBLE || (mSimpleCard != null && mSimpleCard.getVisibility() == View.VISIBLE)) { mSimpleCard.setVisibility(View.GONE); mCard.setVisibility(View.VISIBLE); } } }