List of usage examples for android.util TypedValue COMPLEX_UNIT_PX
int COMPLEX_UNIT_PX
To view the source code for android.util TypedValue COMPLEX_UNIT_PX.
Click Source Link
From source file:com.facebook.widget.GiftTransactionButton.java
/** * Create the LoginButton by inflating from XML * /*from w ww. ja v a 2 s. c om*/ * @see View#View(Context, AttributeSet) */ public GiftTransactionButton(Context context, AttributeSet attrs) { super(context, attrs); if (attrs.getStyleAttribute() == 0) { // apparently there's no method of setting a default style in xml, // so in case the users do not explicitly specify a style, we need // to use sensible defaults. this.setGravity(Gravity.CENTER); this.setTextColor(getResources().getColor(R.color.com_facebook_loginview_text_color)); this.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.com_facebook_loginview_text_size)); this.setTypeface(Typeface.DEFAULT_BOLD); if (isInEditMode()) { // cannot use a drawable in edit mode, so setting the background // color instead // of a background resource. // this.setBackgroundColor(getResources().getColor(R.color.com_facebook_blue)); // hardcoding in edit mode as getResources().getString() doesn't // seem to work in IntelliJ loginText = "Log in with Facebook"; } else { this.setBackgroundResource(R.drawable.btn_doiqua); this.setCompoundDrawablePadding(getResources() .getDimensionPixelSize(R.dimen.com_facebook_loginview_compound_drawable_padding)); // this.setPadding( // getResources().getDimensionPixelSize( // R.dimen.com_facebook_loginview_padding_left), // getResources().getDimensionPixelSize( // R.dimen.com_facebook_loginview_padding_top), // getResources().getDimensionPixelSize( // R.dimen.com_facebook_loginview_padding_right), // getResources().getDimensionPixelSize( // R.dimen.com_facebook_loginview_padding_bottom)); } } parseAttributes(attrs); if (!isInEditMode()) { initializeActiveSessionWithCachedToken(context); } }
From source file:com.sina.android.weibo.sdk.widget.LoginoutButton.java
/** * ??//from www . j av a 2 s . c om * * @param attrs XML ? */ private void loadDefaultStyle(AttributeSet attrs) { if (attrs != null && 0 == attrs.getStyleAttribute()) { Resources res = getResources(); this.setBackgroundResource(R.drawable.com_sina_weibo_sdk_button_blue); this.setPadding(res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_left), res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_top), res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_right), res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_bottom)); this.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_com_sina_weibo_sdk_logo, 0, 0, 0); this.setCompoundDrawablePadding( res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_compound_drawable_padding)); this.setTextColor(res.getColor(R.color.com_sina_weibo_sdk_loginview_text_color)); this.setTextSize(TypedValue.COMPLEX_UNIT_PX, res.getDimension(R.dimen.com_sina_weibo_sdk_loginview_text_size)); this.setTypeface(Typeface.DEFAULT_BOLD); this.setGravity(Gravity.CENTER); this.setText(R.string.com_sina_weibo_sdk_login_with_weibo_account); } }
From source file:com.facebook.widget.LoginButtonDefault.java
/** * Create the LoginButton by inflating from XML * /*from w ww .j a v a 2s. com*/ * @see View#View(Context, AttributeSet) */ public LoginButtonDefault(Context context, AttributeSet attrs) { super(context, attrs); if (attrs.getStyleAttribute() == 0) { // apparently there's no method of setting a default style in xml, // so in case the users do not explicitly specify a style, we need // to use sensible defaults. this.setGravity(Gravity.CENTER); this.setTextColor(getResources().getColor(R.color.com_facebook_loginview_text_color)); this.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.com_facebook_loginview_text_size)); this.setTypeface(Typeface.DEFAULT_BOLD); if (isInEditMode()) { // cannot use a drawable in edit mode, so setting the background // color instead // of a background resource. this.setBackgroundColor(getResources().getColor(R.color.com_facebook_blue)); // hardcoding in edit mode as getResources().getString() doesn't // seem to work in IntelliJ loginText = "Log in with Facebook"; } else { this.setBackgroundResource(R.drawable.com_facebook_button_blue); this.setCompoundDrawablesWithIntrinsicBounds(R.drawable.com_facebook_inverse_icon, 0, 0, 0); this.setCompoundDrawablePadding(getResources() .getDimensionPixelSize(R.dimen.com_facebook_loginview_compound_drawable_padding)); this.setPadding(getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_left), getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_top), getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_right), getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_bottom)); } } parseAttributes(attrs); if (!isInEditMode()) { initializeActiveSessionWithCachedToken(context); } }
From source file:android.support.v7.widget.AppCompatTextHelper.java
@SuppressLint("NewApi") void loadFromAttributes(AttributeSet attrs, int defStyleAttr) { final Context context = mView.getContext(); final AppCompatDrawableManager drawableManager = AppCompatDrawableManager.get(); // First read the TextAppearance style id TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs, R.styleable.AppCompatTextHelper, defStyleAttr, 0);/* w ww . j a va2s .c om*/ final int ap = a.getResourceId(R.styleable.AppCompatTextHelper_android_textAppearance, -1); // Now read the compound drawable and grab any tints if (a.hasValue(R.styleable.AppCompatTextHelper_android_drawableLeft)) { mDrawableLeftTint = createTintInfo(context, drawableManager, a.getResourceId(R.styleable.AppCompatTextHelper_android_drawableLeft, 0)); } if (a.hasValue(R.styleable.AppCompatTextHelper_android_drawableTop)) { mDrawableTopTint = createTintInfo(context, drawableManager, a.getResourceId(R.styleable.AppCompatTextHelper_android_drawableTop, 0)); } if (a.hasValue(R.styleable.AppCompatTextHelper_android_drawableRight)) { mDrawableRightTint = createTintInfo(context, drawableManager, a.getResourceId(R.styleable.AppCompatTextHelper_android_drawableRight, 0)); } if (a.hasValue(R.styleable.AppCompatTextHelper_android_drawableBottom)) { mDrawableBottomTint = createTintInfo(context, drawableManager, a.getResourceId(R.styleable.AppCompatTextHelper_android_drawableBottom, 0)); } a.recycle(); // PasswordTransformationMethod wipes out all other TransformationMethod instances // in TextView's constructor, so we should only set a new transformation method // if we don't have a PasswordTransformationMethod currently... final boolean hasPwdTm = mView.getTransformationMethod() instanceof PasswordTransformationMethod; boolean allCaps = false; boolean allCapsSet = false; ColorStateList textColor = null; ColorStateList textColorHint = null; ColorStateList textColorLink = null; // First check TextAppearance's textAllCaps value if (ap != -1) { a = TintTypedArray.obtainStyledAttributes(context, ap, R.styleable.TextAppearance); if (!hasPwdTm && a.hasValue(R.styleable.TextAppearance_textAllCaps)) { allCapsSet = true; allCaps = a.getBoolean(R.styleable.TextAppearance_textAllCaps, false); } updateTypefaceAndStyle(context, a); if (Build.VERSION.SDK_INT < 23) { // If we're running on < API 23, the text color may contain theme references // so let's re-set using our own inflater if (a.hasValue(R.styleable.TextAppearance_android_textColor)) { textColor = a.getColorStateList(R.styleable.TextAppearance_android_textColor); } if (a.hasValue(R.styleable.TextAppearance_android_textColorHint)) { textColorHint = a.getColorStateList(R.styleable.TextAppearance_android_textColorHint); } if (a.hasValue(R.styleable.TextAppearance_android_textColorLink)) { textColorLink = a.getColorStateList(R.styleable.TextAppearance_android_textColorLink); } } a.recycle(); } // Now read the style's values a = TintTypedArray.obtainStyledAttributes(context, attrs, R.styleable.TextAppearance, defStyleAttr, 0); if (!hasPwdTm && a.hasValue(R.styleable.TextAppearance_textAllCaps)) { allCapsSet = true; allCaps = a.getBoolean(R.styleable.TextAppearance_textAllCaps, false); } if (Build.VERSION.SDK_INT < 23) { // If we're running on < API 23, the text color may contain theme references // so let's re-set using our own inflater if (a.hasValue(R.styleable.TextAppearance_android_textColor)) { textColor = a.getColorStateList(R.styleable.TextAppearance_android_textColor); } if (a.hasValue(R.styleable.TextAppearance_android_textColorHint)) { textColorHint = a.getColorStateList(R.styleable.TextAppearance_android_textColorHint); } if (a.hasValue(R.styleable.TextAppearance_android_textColorLink)) { textColorLink = a.getColorStateList(R.styleable.TextAppearance_android_textColorLink); } } updateTypefaceAndStyle(context, a); a.recycle(); if (textColor != null) { mView.setTextColor(textColor); } if (textColorHint != null) { mView.setHintTextColor(textColorHint); } if (textColorLink != null) { mView.setLinkTextColor(textColorLink); } if (!hasPwdTm && allCapsSet) { setAllCaps(allCaps); } if (mFontTypeface != null) { mView.setTypeface(mFontTypeface, mStyle); } mAutoSizeTextHelper.loadFromAttributes(attrs, defStyleAttr); if (PLATFORM_SUPPORTS_AUTOSIZE) { // Delegate auto-size functionality to the framework implementation. if (mAutoSizeTextHelper.getAutoSizeTextType() != TextViewCompat.AUTO_SIZE_TEXT_TYPE_NONE) { final int[] autoSizeTextSizesInPx = mAutoSizeTextHelper.getAutoSizeTextAvailableSizes(); if (autoSizeTextSizesInPx.length > 0) { if (mView .getAutoSizeStepGranularity() != AppCompatTextViewAutoSizeHelper.UNSET_AUTO_SIZE_UNIFORM_CONFIGURATION_VALUE) { // Configured with granularity, preserve details. mView.setAutoSizeTextTypeUniformWithConfiguration( mAutoSizeTextHelper.getAutoSizeMinTextSize(), mAutoSizeTextHelper.getAutoSizeMaxTextSize(), mAutoSizeTextHelper.getAutoSizeStepGranularity(), TypedValue.COMPLEX_UNIT_PX); } else { mView.setAutoSizeTextTypeUniformWithPresetSizes(autoSizeTextSizesInPx, TypedValue.COMPLEX_UNIT_PX); } } } } }
From source file:com.nxt.njitong.page.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setBackgroundResource(tabBackgroundResId); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); int tabTypefaceStyle = Typeface.NORMAL; tab.setTypeface(tabTypeface, tabTypefaceStyle); tab.setTextColor(tabTextColor); // 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)); }/*www .j a va2 s. c om*/ } if (i == selectedPosition) { tab.setTextColor(selectedTabTextColor); } } } }
From source file:com.waz.zclient.newreg.fragments.EmailAddPhoneFragment.java
private void updatePhoneInputControls(CharSequence charSequence) { phoneConfirmationButton.setState(validatePhoneNumber(charSequence.toString())); if (charSequence.length() == 0) { editTextPhone.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimensionPixelSize(R.dimen.wire__text_size__small)); } else {//from w ww .j ava 2 s . co m editTextPhone.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimensionPixelSize(R.dimen.wire__text_size__regular)); } }
From source file:com.sonvp.tooltip.Tooltip.java
private View getViewTooltip(Builder builder, int backgroundColor) { View toolTip = null;//from w w w .ja v a2 s . co m if (builder.viewTooltip == null) { TextView text = new TextView(builder.context); text.setPadding((int) builder.leftPadding, (int) builder.topPadding, (int) builder.rightPadding, (int) builder.bottomPadding); text.setGravity(builder.textGravity); text.setTextColor(builder.textColor); text.setTextSize(TypedValue.COMPLEX_UNIT_PX, builder.textSize); text.setTypeface(builder.typeface, builder.typefaceStyle); int lines = builder.lines; if (lines > 0) { text.setLines(lines); text.setEllipsize(TextUtils.TruncateAt.END); } CharSequence txt = builder.text; if (TextUtils.isEmpty(txt)) { txt = builder.context.getString(builder.textResourceId); } text.setText(txt); toolTip = text; } else { toolTip = builder.viewTooltip; } float radius = builder.radius; if (radius > 0.0F) { GradientDrawable drawable = new GradientDrawable(); drawable.setColor(backgroundColor); drawable.setGradientType(GradientDrawable.LINEAR_GRADIENT); drawable.setCornerRadius(radius); //noinspection deprecation toolTip.setBackgroundDrawable(drawable); } else { toolTip.setBackgroundColor(backgroundColor); } return toolTip; }
From source file:com.android.mms.rcs.FavoriteDetailAdapter.java
private void initTextMsgView(final TextView bodyText) { bodyText.setText(/*from w w w . ja v a2 s . c o m*/ mCursor.getString(mCursor.getColumnIndexOrThrow(FavoriteMessageProvider.FavoriteMessage.CONTENT))); bodyText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mBodyFontSize); bodyText.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); bodyText.setTextIsSelectable(true); bodyText.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { MessageUtils.onMessageContentClick(mContext, bodyText); } }); }
From source file:m2.android.archetype.example.FacebookSdk.widget.LoginButton.java
/** * Create the LoginButton by inflating from XML * /*from w w w. j av a 2 s .c om*/ * @see View#View(Context, AttributeSet) */ public LoginButton(Context context, AttributeSet attrs) { super(context, attrs); if (attrs.getStyleAttribute() == 0) { // apparently there's no method of setting a default style in xml, // so in case the users do not explicitly specify a style, we need // to use sensible defaults. this.setTextColor(getResources().getColor(R.color.com_facebook_loginview_text_color)); this.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.com_facebook_loginview_text_size)); this.setPadding(getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_left), getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_top), getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_right), getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_bottom)); this.setWidth(getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_width)); this.setHeight(getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_height)); this.setGravity(Gravity.CENTER); parseAttributes(attrs); if (isInEditMode()) { // cannot use a drawable in edit mode, so setting the background // color instead // of a background resource. this.setBackgroundColor(getResources().getColor(R.color.com_facebook_blue)); // hardcoding in edit mode as getResources().getString() doesn't // seem to work in IntelliJ loginText = "Log in"; } else { this.setBackgroundResource(R.drawable.com_facebook_loginbutton_blue); initializeActiveSessionWithCachedToken(context); } } }
From source file:com.wellsandwhistles.android.redditsp.views.RedditPostView.java
public RedditPostView(final Context context, final PostListingFragment fragmentParent, final AppCompatActivity activity) { super(context); mActivity = activity;/*from w ww.ja v a2 s .c o m*/ thumbnailHandler = new Handler(Looper.getMainLooper()) { @Override public void handleMessage(final Message msg) { if (usageId != msg.what) return; thumbnailView.setImageBitmap((Bitmap) msg.obj); } }; dpScale = context.getResources().getDisplayMetrics().density; // TODO xml? final float fontScale = PrefsUtility.appearance_fontscale_posts(context, PreferenceManager.getDefaultSharedPreferences(context)); final View rootView = LayoutInflater.from(context).inflate(R.layout.reddit_post_with_votes, this, true); upvoteArrow = (ImageView) rootView.findViewById(R.id.reddit_post_upvote); downvoteArrow = (ImageView) rootView.findViewById(R.id.reddit_post_downvote); upvoteArrow.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { post.handleVote(mActivity, RedditAPI.ACTION_UPVOTE); } }); downvoteArrow.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { post.handleVote(mActivity, RedditAPI.ACTION_DOWNVOTE); } }); mOuterView = (LinearLayout) rootView.findViewById(R.id.reddit_post_layout); mOuterView.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { fragmentParent.onPostSelected(post); } }); mOuterView.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(final View v) { RedditPreparedPost.showActionMenu(mActivity, post); return true; } }); thumbnailView = (ImageView) rootView.findViewById(R.id.reddit_post_thumbnail_view); //todo alex overlayIcon is where the upvote and downvote are currently going. they are placed over the thumbnail for the posts overlayIcon = (ImageView) rootView.findViewById(R.id.reddit_post_overlay_icon); title = (TextView) rootView.findViewById(R.id.reddit_post_title); subtitle = (TextView) rootView.findViewById(R.id.reddit_post_subtitle); postKarma = (TextView) rootView.findViewById(R.id.reddit_post_karma); commentsButton = (LinearLayout) rootView.findViewById(R.id.reddit_post_comments_button); commentsText = (TextView) commentsButton.findViewById(R.id.reddit_post_comments_text); commentsButton.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { fragmentParent.onPostCommentsSelected(post); } }); title.setTextSize(TypedValue.COMPLEX_UNIT_PX, title.getTextSize() * fontScale); subtitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, subtitle.getTextSize() * fontScale); postKarma.setTextSize(TypedValue.COMPLEX_UNIT_PX, postKarma.getTextSize() * fontScale); final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); mLeftFlingPref = PrefsUtility.pref_behaviour_fling_post_left(context, sharedPreferences); mRightFlingPref = PrefsUtility.pref_behaviour_fling_post_right(context, sharedPreferences); { final TypedArray attr = context .obtainStyledAttributes(new int[] { R.attr.srPostTitleCol, R.attr.srPostTitleReadCol, R.attr.srListItemBackgroundCol, R.attr.srPostCommentsButtonBackCol }); srPostTitleCol = attr.getColor(0, 0); srPostTitleReadCol = attr.getColor(1, 0); srListItemBackgroundCol = attr.getColor(2, 0); srPostCommentsButtonBackCol = attr.getColor(3, 0); attr.recycle(); } }