TextView textViewTitle = (TextView) findViewById(R.id.text_view_title); textViewTitle.setTextAppearance(this, R.style.RedHUGEText);
/** * Sets the text color, size, style, hint color, and highlight color from the specified * <code>TextAppearance</code> resource. * * @param resid the identifier of the resource. */ public void setTextAppearance(Context context, int resid) { if (mTextView != null) { mTextView.setTextAppearance(context, resid); } }
private TextView createViewForTextSwitcher(Context context) { TextView textView = new TextView(context); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { textView.setTextAppearance(R.style.positionIndicatorCurrent); } else { textView.setTextAppearance(context, R.style.positionIndicatorCurrent); } textView.setLayoutParams(new TextSwitcher.LayoutParams(TextSwitcher.LayoutParams.WRAP_CONTENT, TextSwitcher.LayoutParams.WRAP_CONTENT)); return textView; }
TextView title = new TextView(context); title.setTextAppearance(context, android.R.attr.textAppearanceLarge);
@SuppressWarnings("deprecation") @Override public View makeView() { final TextView textView = new TextView(MainActivity.this); if (center) { textView.setGravity(Gravity.CENTER); } if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { textView.setTextAppearance(MainActivity.this, styleId); } else { textView.setTextAppearance(styleId); } return textView; }
/** * A convenience method for setting text appearance. * * @param textView a TextView which textAppearance to modify. * @param resId a style resource for the text appearance. */ @SuppressWarnings("deprecation") protected static void setTextAppearance(@NonNull TextView textView, @StyleRes int resId) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { textView.setTextAppearance(resId); } else { textView.setTextAppearance(textView.getContext(), resId); } }
@SuppressWarnings("deprecation") private void updateCustomTextAppearance() { if (titleView == null || titleTextAppearanceResId == 0) { return; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { titleView.setTextAppearance(titleTextAppearanceResId); } else { titleView.setTextAppearance(getContext(), titleTextAppearanceResId); } titleView.setTag(R.id.bb_bottom_bar_appearance_id, titleTextAppearanceResId); }
public static void setTextAppearance(TextView textView, @StyleRes int textAppearance) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { textView.setTextAppearance(textAppearance); } else { //noinspection deprecation textView.setTextAppearance(textView.getContext(), textAppearance); } }
@TargetApi(Build.VERSION_CODES.M) @Override public void setTextAppearance(int resId) { super.setTextAppearance(resId); if (mTextHelper != null) { mTextHelper.setTextAppearanceForTextColor(resId); } }
@Override public void setTextAppearance(Context context, int resId) { super.setTextAppearance(context, resId); if (mTextHelper != null) { mTextHelper.setTextAppearanceForTextColor(resId); } }
/** * @param resourceId The text appearance resource id. */ public void setHeaderTextAppearance(int resourceId) { title.setTextAppearance(getContext(), resourceId); }
@Override public void setTextAppearance(@NonNull Context context, int resid) { super.setTextAppearance(context, resid); setTextAppearanceInternal(resid, false); }
private void setTextStyle(TextView view, int style) { if (style != 0) { view.setTextAppearance(getContext(), style); } }
public void setTextAppearance(int resId) { mNumber.setTextAppearance(getContext(), resId); }
@Implementation protected void setTextAppearance(Context context, int resid) { textAppearanceId = resid; directlyOn(realTextView, TextView.class).setTextAppearance(context, resid); }
public void setTextAppearance(int resid) { super.setTextAppearance(getContext(), resid); setTextAppearanceInternal(resid, false); }
private void init(Context context) { textSwitcher = new TextSwitcher(context); textSwitcher.addView(createViewForTextSwitcher(context)); textSwitcher.addView(createViewForTextSwitcher(context)); addView(textSwitcher, new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); textView = new TextView(context); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { textView.setTextAppearance(R.style.positionIndicator); } else { textView.setTextAppearance(context, R.style.positionIndicator); } addView(textView, new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); }
private void init(Context context, AttributeSet attrs) { setOrientation(VERTICAL); mDistance = dip2px(context, 54f); LayoutInflater.from(context).inflate(R.layout.load_view, this, true); mShapeLoadingView = (ShapeLoadingView) findViewById(R.id.shapeLoadingView); mIndicationIm = (ImageView) findViewById(R.id.indication); mLoadTextView = (TextView) findViewById(R.id.promptTV); ViewHelper.setScaleX(mIndicationIm, 0.2f); TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.LoadingView); String loadText = typedArray.getString(R.styleable.LoadingView_loadingText); int textAppearance = typedArray.getResourceId(R.styleable.LoadingView_loadingText, -1); mDelay = typedArray.getInteger(R.styleable.LoadingView_delay, 80); typedArray.recycle(); if (textAppearance != -1) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { mLoadTextView.setTextAppearance(textAppearance); } else { mLoadTextView.setTextAppearance(getContext(), textAppearance); } } setLoadingText(loadText); }
int nameTextAppearance = a.getResourceId(R.styleable.ContactView_cv_nameTextAppearance, 0); if(nameTextAppearance > 0) mNameView.setTextAppearance(context, nameTextAppearance); if(nameTextSize > 0) mNameView.setTextSize(TypedValue.COMPLEX_UNIT_PX, nameTextSize); int addressTextAppearance = a.getResourceId(R.styleable.ContactView_cv_addressTextAppearance, 0); if(addressTextAppearance > 0) mAddressView.setTextAppearance(context, addressTextAppearance); if(addressTextSize > 0) mAddressView.setTextSize(TypedValue.COMPLEX_UNIT_PX, addressTextSize);
@Test public void testGetTextAppearanceId() throws Exception { textView.setTextAppearance( ApplicationProvider.getApplicationContext(), android.R.style.TextAppearance_Small); assertThat(shadowOf(textView).getTextAppearanceId()).isEqualTo(android.R.style.TextAppearance_Small); }