當前位置: 首頁>>代碼示例>>Java>>正文


Java TextView.setTextAppearance方法代碼示例

本文整理匯總了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;
}
 
開發者ID:Ramotion,項目名稱:showroom-android,代碼行數:18,代碼來源:CardSliderActivity.java

示例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));
}
 
開發者ID:Ramotion,項目名稱:showroom-android,代碼行數:17,代碼來源:ItemsCountView.java

示例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);
  }
}
 
開發者ID:nhocga1995s,項目名稱:MyCalendar,代碼行數:19,代碼來源:FloatingActionsMenu.java

示例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();
}
 
開發者ID:yangchong211,項目名稱:YCCustomText,代碼行數:31,代碼來源:LabeledEditText.java

示例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;
}
 
開發者ID:zongkaili,項目名稱:MenuSet,代碼行數:30,代碼來源:Utils.java

示例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);
    }
}
 
開發者ID:coffeeplanter,項目名稱:SimpleNotes,代碼行數:10,代碼來源:NoteAdapter.java

示例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;

}
 
開發者ID:nhocga1995s,項目名稱:MyCalendar,代碼行數:14,代碼來源:MainActivity.java

示例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;
}
 
開發者ID:leobert-lan,項目名稱:UiLib,代碼行數:15,代碼來源:EasySwitcher.java

示例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);
}
 
開發者ID:AnywhereSoftware,項目名稱:B4A_ViewsEx,代碼行數:30,代碼來源:FloatLabeledEditText.java

示例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);
}
 
開發者ID:ur13l,項目名稱:Guanajoven,代碼行數:75,代碼來源:ExtendedCalendarView.java

示例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);
    }
}
 
開發者ID:A-Miracle,項目名稱:QiangHongBao,代碼行數:15,代碼來源:MiscUtils.java

示例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);
    }
}
 
開發者ID:MFlisar,項目名稱:RecyclerViewPreferences,代碼行數:9,代碼來源:Util.java

示例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;
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:54,代碼來源:ItemPropertiesAdapter.java

示例14: setTextAppearance

import android.widget.TextView; //導入方法依賴的package包/類
static void setTextAppearance(TextView textView, int resId) {
    textView.setTextAppearance(textView.getContext(), resId);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:4,代碼來源:TextViewCompatDonut.java

示例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);
	}
  }
}
 
開發者ID:TIIEHenry,項目名稱:TIIEHenry-Android-SDK,代碼行數:81,代碼來源:TabLayout.java


注:本文中的android.widget.TextView.setTextAppearance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。