本文整理汇总了Java中android.widget.TextView.setTextAppearance方法的典型用法代码示例。如果您正苦于以下问题:Java TextView.setTextAppearance方法的具体用法?Java TextView.setTextAppearance怎么用?Java TextView.setTextAppearance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.TextView
的用法示例。
在下文中一共展示了TextView.setTextAppearance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeView
import android.widget.TextView; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public View makeView() {
final TextView textView = new TextView(CardSliderActivity.this);
if (center) {
textView.setGravity(Gravity.CENTER);
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
textView.setTextAppearance(CardSliderActivity.this, styleId);
} else {
textView.setTextAppearance(styleId);
}
return textView;
}
示例2: init
import android.widget.TextView; //导入方法依赖的package包/类
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.EcPositionIndicator);
} else {
textView.setTextAppearance(context, R.style.EcPositionIndicator);
}
addView(textView, new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
}
示例3: createLabels
import android.widget.TextView; //导入方法依赖的package包/类
private void createLabels() {
Context context = new ContextThemeWrapper(getContext(), mLabelsStyle);
for (int i = 0; i < mButtonsCount; i++) {
FloatingActionButtonLibrary button = (FloatingActionButtonLibrary) getChildAt(i);
String title = button.getTitle();
if (button == mAddButton || title == null ||
button.getTag(R.id.fab_label) != null) continue;
TextView label = new TextView(context);
label.setTextAppearance(getContext(), mLabelsStyle);
label.setText(button.getTitle());
addView(label);
button.setTag(R.id.fab_label, label);
}
}
示例4: setAttributes
import android.widget.TextView; //导入方法依赖的package包/类
private void setAttributes(AttributeSet attrs) {
mHintTextView = new TextView(mContext);
final TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.LabeledEditText);
final int padding = a.getDimensionPixelSize(R.styleable.LabeledEditText_etPadding, 0);
final int defaultPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
DEFAULT_PADDING_LEFT, getResources().getDisplayMetrics());
final int paddingLeft = a.getDimensionPixelSize(R.styleable.LabeledEditText_etPaddingLeft, defaultPadding);
final int paddingTop = a.getDimensionPixelSize(R.styleable.LabeledEditText_etPaddingTop, 0);
final int paddingRight = a.getDimensionPixelSize(R.styleable.LabeledEditText_etPaddingRight, 0);
final int paddingBottom = a.getDimensionPixelSize(R.styleable.LabeledEditText_etPaddingBottom, 0);
Drawable background = a.getDrawable(R.styleable.LabeledEditText_etBackground);
if (padding != 0) {
mHintTextView.setPadding(padding, padding, padding, padding);
} else {
mHintTextView.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
}
if (background != null) {
setHintBackground(background);
}
mHintTextView.setTextAppearance(mContext, a.getResourceId(R.styleable.LabeledEditText_etTextAppearance,
android.R.style.TextAppearance_Small));
//Start hidden
mHintTextView.setVisibility(INVISIBLE);
//AnimatorProxy.wrap(mHintTextView).setAlpha(0);
addView(mHintTextView, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
a.recycle();
}
示例5: getItemTextView
import android.widget.TextView; //导入方法依赖的package包/类
public static TextView getItemTextView(Context context, MenuObject menuItem, int menuItemSize,
View.OnClickListener onCLick, View.OnLongClickListener onLongClick) {
TextView itemTextView = new TextView(context);
RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, menuItemSize);
itemTextView.setLayoutParams(textLayoutParams);
itemTextView.setOnClickListener(onCLick);
itemTextView.setOnLongClickListener(onLongClick);
itemTextView.setText(menuItem.getTitle());
itemTextView.setPadding(0, 0, (int) context.getResources().getDimension(R.dimen.text_right_padding), 0);
itemTextView.setGravity(Gravity.CENTER_VERTICAL);
int textColor = menuItem.getTextColor() == 0 ?
android.R.color.white :
menuItem.getTextColor();
itemTextView.setTextColor(ContextCompat.getColor(context, textColor));
int styleResId = menuItem.getMenuTextAppearanceStyle() > 0
? menuItem.getMenuTextAppearanceStyle()
: R.style.TextView_DefaultStyle;
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.M) {
itemTextView.setTextAppearance(context, styleResId);
} else {
itemTextView.setTextAppearance(styleResId);
}
return itemTextView;
}
示例6: setTextAppearance
import android.widget.TextView; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private void setTextAppearance(Context context, TextView textView, int resId) {
if (Build.VERSION.SDK_INT < 23) {
textView.setTextAppearance(context, resId);
}
else {
textView.setTextAppearance(resId);
}
}
示例7: createTextView
import android.widget.TextView; //导入方法依赖的package包/类
private TextView createTextView(Context context, String s, int minHeight, int marginTop, int marginBottom, int marginLeftRight) {
TextView tv = new TextView(context);
LinearLayout.LayoutParams params =
new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.setMargins(marginLeftRight, marginTop, marginLeftRight, marginBottom);
tv.setLayoutParams(params);
tv.setText(s);
tv.setGravity(Gravity.CENTER);
tv.setMinHeight(minHeight);
tv.setTextAppearance(mContext, R.style.TextAppearance_AppCompat_Caption);
return tv;
}
示例8: getItemView
import android.widget.TextView; //导入方法依赖的package包/类
private View getItemView(int position){
TextView textView = new TextView(mContext);
textView.setTextAppearance(mContext, R.style.switcher_item_text_style);
LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,
DensityUtil.dip2px(mContext, 35));
textView.setLayoutParams(layoutParams);
textView.setSelected(position == mDefaultSelection);
textView.setGravity(Gravity.CENTER);
textView.setText(mAllItemArray.get(position));
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12.0f);
textView.setOnClickListener(mItemOnClickListener);
textView.setTag(position);
return textView;
}
示例9: setAttributes
import android.widget.TextView; //导入方法依赖的package包/类
private void setAttributes(AttributeSet attrs) {
mHintTextView = new TextView(mContext);
final int padding = 0;
final int defaultPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, DEFAULT_PADDING_LEFT, getResources().getDisplayMetrics());
final int paddingLeft = defaultPadding;
final int paddingTop = 0;
final int paddingRight = 0;
final int paddingBottom = 0;
Drawable background = null;
if (padding != 0) {
mHintTextView.setPadding(padding, padding, padding, padding);
} else {
mHintTextView.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
}
if (background != null) {
setHintBackground(background);
}
mHintTextView.setTextAppearance(mContext, android.R.style.TextAppearance_Small);
//Start hidden
mHintTextView.setVisibility(INVISIBLE);
addView(mHintTextView, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
}
示例10: init
import android.widget.TextView; //导入方法依赖的package包/类
private void init(){
cal = Calendar.getInstance();
base = new RelativeLayout(context);
base.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT));
base.setMinimumHeight(50);
base.setId(4);
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
params.leftMargin = 16;
params.topMargin = 50;
params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
params.addRule(RelativeLayout.CENTER_VERTICAL);
prev = new ImageView(context);
prev.setId(1);
prev.setLayoutParams(params);
prev.setImageResource(R.drawable.navigation_previous_item);
prev.setOnClickListener(this);
base.addView(prev);
params = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.CENTER_HORIZONTAL);
params.addRule(RelativeLayout.CENTER_VERTICAL);
month = new TextView(context);
month.setId(2);
month.setLayoutParams(params);
month.setTextAppearance(context, android.R.attr.textAppearanceLarge);
month.setText(cal.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.getDefault())+" "+cal.get(Calendar.YEAR));
month.setTextSize(25);
base.addView(month);
params = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
params.rightMargin = 16;
params.topMargin = 50;
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
params.addRule(RelativeLayout.CENTER_VERTICAL);
next = new ImageView(context);
next.setImageResource(R.drawable.navigation_next_item);
next.setLayoutParams(params);
next.setId(3);
next.setOnClickListener(this);
base.addView(next);
addView(base);
params = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
params.bottomMargin = 20;
params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
params.addRule(RelativeLayout.BELOW, base.getId());
calendar = new GridView(context);
calendar.setLayoutParams(params);
calendar.setVerticalSpacing(4);
calendar.setHorizontalSpacing(4);
calendar.setNumColumns(7);
calendar.setChoiceMode(GridView.CHOICE_MODE_SINGLE);
calendar.setDrawSelectorOnTop(true);
calendar.setFocusable(false);
mAdapter = new CalendarAdapter(context,cal);
calendar.setAdapter(mAdapter);
calendar.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return calendarGesture.onTouchEvent(event);
}
});
addView(calendar);
}
示例11: setTextAppearance
import android.widget.TextView; //导入方法依赖的package包/类
/**
* 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(TextView textView, int resId) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
textView.setTextAppearance(resId);
} else {
textView.setTextAppearance(textView.getContext(), resId);
}
}
示例12: setTextAppearance
import android.widget.TextView; //导入方法依赖的package包/类
public static void setTextAppearance(TextView tv, int textAppearance) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
tv.setTextAppearance(textAppearance);
} else {
//noinspection deprecation
tv.setTextAppearance(tv.getContext(), textAppearance);
}
}
示例13: getView
import android.widget.TextView; //导入方法依赖的package包/类
@Override
public View getView(final int position, View convertView, ViewGroup parent)
{
//Log.v(L.TAG, "ItemPropertiesAdapter.getView() called");
View rv = null;
try
{
if(convertView == null)
{
rv = View.inflate(context, R.layout.item_entry, null);
}
else
{
rv = convertView;
}
ItemDesc it = dataViewer.getItemData().get(position);
TextView t1 = (TextView)rv.findViewById(R.id.text1);
t1.setText(it.getLabel());
t1.setTextAppearance(context, it.isActive()?R.style.ActiveText:R.style.InactiveText);
if(it.isActive())
{
t1.setPaintFlags(t1.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
}
else
{
t1.setPaintFlags(t1.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}
ImageSwitcher starSwitch = (ImageSwitcher)rv.findViewById(R.id.StarSwitcher);
starSwitch.setVisibility(it.isStar()?View.VISIBLE:View.INVISIBLE);
starSwitch.setDisplayedChild(it.isActive()?0:1);
View sortedMarker = (View)rv.findViewById(R.id.SortedMarker);
if(it.isSorted())
{
sortedMarker.setVisibility(View.INVISIBLE);
}
else
{
sortedMarker.setVisibility(View.VISIBLE);
}
}
catch(Exception e)
{
Log.e(L.TAG, "Error in getView()", e);
}
return rv;
}
示例14: setTextAppearance
import android.widget.TextView; //导入方法依赖的package包/类
static void setTextAppearance(TextView textView, int resId) {
textView.setTextAppearance(textView.getContext(), resId);
}
示例15: update
import android.widget.TextView; //导入方法依赖的package包/类
final void update() {
final Tab tab = mTab;
final View custom = tab.getCustomView();
if (custom != null) {
final ViewParent customParent = custom.getParent();
if (customParent != this) {
if (customParent != null) {
((ViewGroup) customParent).removeView(custom);
}
addView(custom);
}
mCustomView = custom;
if (mTextView != null) {
mTextView.setVisibility(GONE);
}
if (mIconView != null) {
mIconView.setVisibility(GONE);
mIconView.setImageDrawable(null);
}
} else {
if (mCustomView != null) {
removeView(mCustomView);
mCustomView = null;
}
final Drawable icon = tab.getIcon();
final CharSequence text = tab.getText();
if (icon != null) {
if (mIconView == null) {
ImageView iconView = new ImageView(getContext());
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.CENTER_VERTICAL;
iconView.setLayoutParams(lp);
addView(iconView, 0);
mIconView = iconView;
}
mIconView.setImageDrawable(icon);
mIconView.setVisibility(VISIBLE);
} else if (mIconView != null) {
mIconView.setVisibility(GONE);
mIconView.setImageDrawable(null);
}
final boolean hasText = !TextUtils.isEmpty(text);
if (hasText) {
if (mTextView == null) {
TextView textView = new TextView(getContext());
textView.setTextAppearance(getContext(), mTabTextAppearance);
textView.setMaxLines(MAX_TAB_TEXT_LINES);
textView.setEllipsize(TextUtils.TruncateAt.END);
textView.setGravity(Gravity.CENTER);
if (mTabSelectedTextColorSet) {
textView.setTextColor(createColorStateList(
textView.getCurrentTextColor(), mTabSelectedTextColor));
}
addView(textView, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
mTextView = textView;
}
mTextView.setText(text);
mTextView.setVisibility(VISIBLE);
} else if (mTextView != null) {
mTextView.setVisibility(GONE);
mTextView.setText(null);
}
if (mIconView != null) {
mIconView.setContentDescription(tab.getContentDescription());
}
if (!hasText && !TextUtils.isEmpty(tab.getContentDescription())) {
setOnLongClickListener(this);
} else {
setOnLongClickListener(null);
setLongClickable(false);
}
}
}