当前位置: 首页>>代码示例>>Java>>正文


Java TypedValue类代码示例

本文整理汇总了Java中android.util.TypedValue的典型用法代码示例。如果您正苦于以下问题:Java TypedValue类的具体用法?Java TypedValue怎么用?Java TypedValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TypedValue类属于android.util包,在下文中一共展示了TypedValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: appleStyleAfterCreated

import android.util.TypedValue; //导入依赖的package包/类
/**
 * Process view after created.
 *
 * @param editText
 */
protected void appleStyleAfterCreated(WXEditText editText) {
  String alignStr = (String) getDomObject().getStyles().get(Constants.Name.TEXT_ALIGN);
  int textAlign = getTextAlign(alignStr);
  if (textAlign <= 0) {
    textAlign = Gravity.LEFT;
  }
  editText.setGravity(textAlign | Gravity.CENTER_VERTICAL);
  int colorInt = WXResourceUtils.getColor("#999999");
  if (colorInt != Integer.MIN_VALUE) {
    editText.setHintTextColor(colorInt);
  }

  editText.setTextSize(TypedValue.COMPLEX_UNIT_PX, WXStyle.getFontSize(getDomObject().getStyles()));
  editText.setText(getDomObject().getAttrs().optString(Constants.Name.VALUE));
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:21,代码来源:AbstractEditComponent.java

示例2: createTextView

import android.util.TypedValue; //导入依赖的package包/类
private View createTextView(String text) {

        final TextView textView = new TextView(getContext());
        textView.setText(text);
        textView.setGravity(Gravity.CENTER);
        textView.setSingleLine();
        textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
        textView.setTextColor(textColor);


        return new TabView(PagerTabsIndicator.this.getContext(), textView) {
            @Override
            public void onOffset(float offset) {
                super.onOffset(offset);
                if (highlightText) {
                    ((TextView) getChildAt(0)).setTextColor(Util.mixTwoColors(highlightTextColor, textColor, offset));
                }
            }
        };
    }
 
开发者ID:Crysis21,项目名称:PagerTabIndicator,代码行数:21,代码来源:PagerTabsIndicator.java

示例3: setDefault

import android.util.TypedValue; //导入依赖的package包/类
private void setDefault(float size) {
    setGravity(Gravity.CENTER);
    setTextColor(Color.WHITE);

    DisplayMetrics metrics = getResources().getDisplayMetrics();
    if (size <= 0) {
        mSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 14, metrics);
    } else {
        mSize = size;
    }

    if (metrics.density <= 1.5) {
        setTextSize(TypedValue.COMPLEX_UNIT_DIP, 9);
    } else {
        setTextSize(TypedValue.COMPLEX_UNIT_SP, 10);
    }

    int paddingLeft = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 3, metrics);
    int paddingRight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 3, metrics);

    setPadding(paddingLeft, 0, paddingRight, 0);

    change();
}
 
开发者ID:ryanlijianchang,项目名称:AdPlayBanner,代码行数:25,代码来源:PointView.java

示例4: setBlogLink

import android.util.TypedValue; //导入依赖的package包/类
public void setBlogLink(final GroupId groupId) {
	setClickable(true);
	TypedValue outValue = new TypedValue();
	getContext().getTheme().resolveAttribute(
			android.R.attr.selectableItemBackground, outValue, true);
	setBackgroundResource(outValue.resourceId);
	setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View v) {
			Intent i = new Intent(getContext(), BlogActivity.class);
			i.putExtra(GROUP_ID, groupId.getBytes());
			i.setFlags(FLAG_ACTIVITY_CLEAR_TOP);
			getContext().startActivity(i);
		}
	});
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:17,代码来源:AuthorView.java

示例5: onCustomiseDialog

import android.util.TypedValue; //导入依赖的package包/类
@Override
protected @NonNull DynamicDialog onCustomiseDialog(@NonNull DynamicDialog alertDialog,
                                                   @Nullable Bundle savedInstanceState) {
    View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_about,
            new LinearLayout(getContext()), false);
    TextView message = view.findViewById(R.id.dialog_about_text);

    message.setText(Html.fromHtml(getString(R.string.about_content)
            .replace("\n", "<br/>")));
    message.setTextSize(TypedValue.COMPLEX_UNIT_SP, TEXT_SIZE);
    message.setLineSpacing(0f, 1.2f);
    message.setMovementMethod(LinkMovementMethod.getInstance());
    message.setLinkTextColor(ContextCompat.getColor(getContext(), R.color.colorPrimary));

    alertDialog.setView(view);
    return alertDialog;
}
 
开发者ID:pranavpandey,项目名称:dynamic-toasts,代码行数:18,代码来源:AboutDialogFragment.java

示例6: makeTextView

import android.util.TypedValue; //导入依赖的package包/类
private void makeTextView() {
    loadTextViewStyleAttributes();
    textView.setText(text);
    if (textColor != 0) {
        textView.setTextColor(textColor);
    }

    if (textSize > 0) {
        textView.setTextSize(isTextSizeFromStyle ? 0 : TypedValue.COMPLEX_UNIT_SP, textSize);
    }

    if (textBold && typeface == null) {
        textView.setTypeface(Typeface.create(context.getString(R.string.default_font), Typeface.BOLD));
    } else if (textBold) {
        textView.setTypeface(Typeface.create(typeface, Typeface.BOLD));
    } else if (typeface != null) {
        textView.setTypeface(typeface);
        //TODO THIS CHECK IS DEPRECATED AND WILL BE DELETED SOON
    } else if (fontId > 0) {
        textView.setTypeface(ResourcesCompat.getFont(context, fontId));
    }
}
 
开发者ID:Muddz,项目名称:StyleableToast,代码行数:23,代码来源:StyleableToast.java

示例7: applyDimension

import android.util.TypedValue; //导入依赖的package包/类
/**
 * 各种单位转换
 * <p>该方法存在于TypedValue</p>
 *
 * @param unit    单位
 * @param value   值
 * @param metrics DisplayMetrics
 * @return 转换结果
 */
public static float applyDimension(int unit, float value, DisplayMetrics metrics) {
    switch (unit) {
        case TypedValue.COMPLEX_UNIT_PX:
            return value;
        case TypedValue.COMPLEX_UNIT_DIP:
            return value * metrics.density;
        case TypedValue.COMPLEX_UNIT_SP:
            return value * metrics.scaledDensity;
        case TypedValue.COMPLEX_UNIT_PT:
            return value * metrics.xdpi * (1.0f / 72);
        case TypedValue.COMPLEX_UNIT_IN:
            return value * metrics.xdpi;
        case TypedValue.COMPLEX_UNIT_MM:
            return value * metrics.xdpi * (1.0f / 25.4f);
    }
    return 0;
}
 
开发者ID:zhongjuncoder,项目名称:AggregationNews,代码行数:27,代码来源:SizeUtils.java

示例8: selectedBank

import android.util.TypedValue; //导入依赖的package包/类
private void selectedBank(final GiroPayIssuer bank) {
    editText.removeTextChangedListener(giroPayTextWatcher);
    editText.setText(bank.getBankName());
    editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
    editText.setSingleLine(false);
    editText.clearFocus();
    editText.setEnabled(false);
    editText.setCancelDrawable(AppCompatResources.getDrawable(getContext(), R.drawable.clear_icon),
            new GiroPayEditText.OnDrawableClickListener() {
        @Override
        public void onDrawableClick() {
            unSelectedBank();
        }
    });

    issuerListAdapter.clearData();
    issuerListAdapter.notifyDataSetChanged();

    InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(editText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);

    payButton.setEnabled(true);
}
 
开发者ID:Adyen,项目名称:adyen-android,代码行数:24,代码来源:GiropayFragment.java

示例9: applyStyle

import android.util.TypedValue; //导入依赖的package包/类
@Override
public final void applyStyle(MessagesListStyle style) {
    super.applyStyle(style);
    if (bubble != null) {
        bubble.setPadding(style.getOutcomingDefaultBubblePaddingLeft(),
                style.getOutcomingDefaultBubblePaddingTop(),
                style.getOutcomingDefaultBubblePaddingRight(),
                style.getOutcomingDefaultBubblePaddingBottom());
        ViewCompat.setBackground(bubble, style.getOutcomingBubbleDrawable());
    }

    if (text != null) {
        text.setTextColor(style.getOutcomingTextColor());
        text.setTextSize(TypedValue.COMPLEX_UNIT_PX, style.getOutcomingTextSize());
        text.setTypeface(text.getTypeface(), style.getOutcomingTextStyle());
        text.setAutoLinkMask(style.getTextAutoLinkMask());
        text.setLinkTextColor(style.getOutcomingTextLinkColor());
        configureLinksBehavior(text);
    }
}
 
开发者ID:sciage,项目名称:FinalProject,代码行数:21,代码来源:MessageHolders.java

示例10: onFinishInflate

import android.util.TypedValue; //导入依赖的package包/类
@Override
protected void onFinishInflate() {
    super.onFinishInflate();

    contentContainer = view.findViewById(R.id.relativeLayout_swipeBtn_contentContainer);
    arrowHintContainer = view.findViewById(R.id.linearLayout_swipeBtn_hintContainer);
    contentTv = view.findViewById(R.id.tv_btnText);
    arrow1 = view.findViewById(R.id.iv_arrow1);
    arrow2 = view.findViewById(R.id.iv_arrow2);

    tintArrowHint();
    contentTv.setText(btnText);
    contentTv.setTextColor(textColorInt);
    contentTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    gradientDrawable = new GradientDrawable();
    gradientDrawable.setShape(GradientDrawable.RECTANGLE);
    gradientDrawable.setCornerRadius(btnRadius);
    setBackgroundColor(bgColorInt);
    updateBackground();
    setupTouchListener();
}
 
开发者ID:shadowfaxtech,项目名称:proSwipeButton,代码行数:22,代码来源:ProSwipeButton.java

示例11: createDefaultTabView

import android.util.TypedValue; //导入依赖的package包/类
/**
 * 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)}.
 */
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);

    return textView;
}
 
开发者ID:NEYouFan,项目名称:ht-viewpagerwithindicator,代码行数:30,代码来源:SlidingTabLayout.java

示例12: generateTopBarTextButton

import android.util.TypedValue; //导入依赖的package包/类
/**
 * 生成一个文本按钮,并设置文字
 *
 * @param text 按钮的文字
 * @return
 */
private Button generateTopBarTextButton(String text) {
    Button button = new Button(getContext());
    button.setBackgroundResource(0);
    button.setMinWidth(0);
    button.setMinHeight(0);
    button.setMinimumWidth(0);
    button.setMinimumHeight(0);
    int paddingHorizontal = getTopBarTextBtnPaddingHorizontal();
    button.setPadding(paddingHorizontal, 0, paddingHorizontal, 0);
    button.setTextColor(QMUIResHelper.getAttrColorStateList(getContext(), R.attr.qmui_topbar_text_btn_color_state_list));
    button.setTextSize(TypedValue.COMPLEX_UNIT_PX, QMUIResHelper.getAttrDimen(getContext(), R.attr.qmui_topbar_text_btn_text_size));
    button.setGravity(Gravity.CENTER);
    button.setText(text);
    return button;
}
 
开发者ID:coopese,项目名称:qmui,代码行数:22,代码来源:QMUITopBar.java

示例13: initBottomText

import android.util.TypedValue; //导入依赖的package包/类
private void initBottomText() {
    TextView splashTitle = findViewById(R.id.splash_title);
    if (splashTitle != null) {
        splashTitle.setText(mConfig.getBottomText());

        if (mConfig.getBottomTextColor() != -1) {
            splashTitle.setTextColor(mConfig.getBottomTextColor());
        } else {
            int color = ContextCompat.getColor(this, R.color.splashColor);
            splashTitle.setTextColor(ColorHelper.getBodyTextColor(color));
        }

        splashTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, mConfig.getBottomTextSize());
        splashTitle.setTypeface(mConfig.getBottomTextFont(this));
    }
}
 
开发者ID:danimahardhika,项目名称:wallpaperboard,代码行数:17,代码来源:WallpaperBoardSplashActivity.java

示例14: init

import android.util.TypedValue; //导入依赖的package包/类
private void init(Context context, int drawableId, String text, int textColor, String typefacePath) {
	reset();
	if (drawableId > 0) setMagicSrc(drawableId);

	mTextView = mEditMode ? new EditText(context) : new TextView(context);
	//不要用LayoutParams.WRAP_CONTENT,否则每次设置文本都会引发requestLayout()
	addView(mTextView, new LayoutParams(0, 0));
	mTextView.addTextChangedListener(mTextWatcher);
	mTextView.setBackgroundResource(0);
	mTextView.setPadding(0, 0, 0, 0);	//paddings会导致文本的遮盖,对于EditText, 即使将背景置为null, 也还会有padding
	mTextView.setTextColor(textColor);
	mTextView.setGravity(Gravity.CENTER);
	if (typefacePath != null) setTextFont(typefacePath.startsWith("asset:"), typefacePath);

	DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
	//DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
	//mUnitInPx = (int)(displayMetrics.density * 2 + 0.5f);
	//if (!mEditMode) mUnitInPx *= 2;
	if (mMinTextSize <= 0) mMinTextSize = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 9, displayMetrics);
	if (mMaxTextSize <= 0) mMaxTextSize = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 80, displayMetrics);
	if (mMinTextSize > mMaxTextSize) throw new IllegalArgumentException("字号范围设置错误:[" + mMinTextSize + ", " + mMaxTextSize + "]");
	scaleTextSize(1);
	mTextSize = mMinTextSizeScaled;
	setTextSize(mTextSize);
	setText(text);
}
 
开发者ID:isuhao,项目名称:QMark,代码行数:27,代码来源:MagicBoardView.java

示例15: createAnimator

import android.util.TypedValue; //导入依赖的package包/类
@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {
    if (startValues == null || endValues == null) {
        return null;
    }

    Float startSize = (Float) startValues.values.get(PROPNAME_TEXT_SIZE);
    Float endSize = (Float) endValues.values.get(PROPNAME_TEXT_SIZE);
    if (startSize == null || endSize == null || startSize.floatValue() == endSize.floatValue()) {
        return null;
    }

    TextView view = (TextView) endValues.view;
    view.setTextSize(TypedValue.COMPLEX_UNIT_PX, startSize);
    return ObjectAnimator.ofFloat(view, TEXT_SIZE_PROPERTY, startSize, endSize);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:TextSizeTransition.java


注:本文中的android.util.TypedValue类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。