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


Java TextView.setTypeface方法代碼示例

本文整理匯總了Java中android.widget.TextView.setTypeface方法的典型用法代碼示例。如果您正苦於以下問題:Java TextView.setTypeface方法的具體用法?Java TextView.setTypeface怎麽用?Java TextView.setTypeface使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.TextView的用法示例。


在下文中一共展示了TextView.setTypeface方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getView

import android.widget.TextView; //導入方法依賴的package包/類
/****************************************************************
 * getView
 * 		the overroad getView method */
public View getView(int position, View convertView, ViewGroup parent) 
{
	// get the view that would normally be returned
	View v = super.getView(position, convertView, parent);
	final TextView tv = (TextView) v;
	
	final String option = tv.getText().toString();			
	if (option.equals("Serif"))
		tv.setTypeface(Typeface.SERIF);
	else if (option.equals("Sans Serif"))
		tv.setTypeface(Typeface.SANS_SERIF);
	else if (option.equals("Monospace"))
		tv.setTypeface(Typeface.MONOSPACE);

	// general options
	tv.setTextColor(Color.BLACK);
	tv.setPadding(10, 3, 3, 3);

	return v;	
}
 
開發者ID:starn,項目名稱:encdroidMC,代碼行數:24,代碼來源:FontTypePreference.java

示例2: applyFontsToTitle

import android.widget.TextView; //導入方法依賴的package包/類
private void applyFontsToTitle(Toolbar toolbar) {
    int childCount = toolbar.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = toolbar.getChildAt(i);
        if (child instanceof TextView) {
            TextView tv = (TextView) child;
            tv.setTextSize(getResources().getDimensionPixelSize(R.dimen.font_text_size));
            Typeface titleFont = Typeface.
                    createFromAsset(getAssets(), "fonts/AlexBrush-Regular.ttf");
            if (tv.getText().equals(toolbar.getTitle())) {
                tv.setTypeface(titleFont);
                break;
            }
        }
    }
}
 
開發者ID:Assassinss,項目名稱:Moment,代碼行數:17,代碼來源:MainActivity.java

示例3: fill

import android.widget.TextView; //導入方法依賴的package包/類
/**
 * Fill list item with data from Post object.
 *
 * @param post Object to load data from.
 */
public void fill(Post post) {
    checkNotNull(post);

    // Set text values
    TextView preview = ButterKnife.findById(this, R.id.contents_preview);
    String previewText = Html.fromHtml(post.getContents()).toString();
    preview.setText(previewText);
    preview.setTypeface((post.isRead() && !post.isUpdated()) ? Typeface.DEFAULT : Typeface.DEFAULT_BOLD);

    View bookmarkView = ButterKnife.findById(this, R.id.bookmark_image);
    bookmarkView.setVisibility(post.isBookmarked() ? VISIBLE : GONE);

    View updatedView = ButterKnife.findById(this, R.id.updated_image);
    updatedView.setVisibility(post.isUpdated() ? VISIBLE : GONE);

    // Attach dispenser to view
    setTag(post);
}
 
開發者ID:tbolender,項目名稱:fefereader,代碼行數:24,代碼來源:PostListItem.java

示例4: setTypeface

import android.widget.TextView; //導入方法依賴的package包/類
public ViewHolder setTypeface(Typeface typeface, int... viewIds)
{
    for (int viewId : viewIds)
    {
        TextView view = getView(viewId);
        view.setTypeface(typeface);
        view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
    }
    return this;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:11,代碼來源:ViewHolder.java

示例5: AlbumView

import android.widget.TextView; //導入方法依賴的package包/類
public AlbumView(Context context) {
    super(context);

    imageView = new BackupImageView(context);
    addView(imageView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    linearLayout.setBackgroundColor(0x7f000000);
    addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 28, Gravity.LEFT | Gravity.BOTTOM));

    nameTextView = new TextView(context);
    nameTextView.setTypeface(FontManager.instance().getTypeface());
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    nameTextView.setTextColor(0xffffffff);
    nameTextView.setSingleLine(true);
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    nameTextView.setMaxLines(1);
    nameTextView.setGravity(Gravity.CENTER_VERTICAL);
    linearLayout.addView(nameTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, 8, 0, 0, 0));

    countTextView = new TextView(context);
    countTextView.setTypeface(FontManager.instance().getTypeface());
    countTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    countTextView.setTextColor(0xffaaaaaa);
    countTextView.setSingleLine(true);
    countTextView.setEllipsize(TextUtils.TruncateAt.END);
    countTextView.setMaxLines(1);
    countTextView.setGravity(Gravity.CENTER_VERTICAL);
    linearLayout.addView(countTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, 4, 0, 4, 0));

    selector = new View(context);
    selector.setBackgroundResource(R.drawable.list_selector);
    addView(selector, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:36,代碼來源:PhotoPickerAlbumsCell.java

示例6: setUpViews

import android.widget.TextView; //導入方法依賴的package包/類
private void setUpViews() {
    TextView textView1  = (TextView) findViewById(R.id.textView1);
    TextView textView2  = (TextView) findViewById(R.id.textView2);
    TextView textView3  = (TextView) findViewById(R.id.textView3);
    TextView textView4  = (TextView) findViewById(R.id.textView4);

    textView1.setTypeface(pfBeausans);
    textView2.setTypeface(pfBeausans);
    textView3.setTypeface(pfBeausans);
    textView4.setTypeface(pfBeausans);
}
 
開發者ID:caiovidaln,項目名稱:ifcalc,代碼行數:12,代碼來源:PoliticaPrivacidadeActivity.java

示例7: custom

import android.widget.TextView; //導入方法依賴的package包/類
@CheckResult
public static Toast custom(@NonNull Context context, @NonNull CharSequence message, Drawable icon,
                           @ColorInt int tintColor, int duration,
                           boolean withIcon, boolean shouldTint) {
    final Toast currentToast = new Toast(context);
    final View toastLayout = ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
            .inflate(R.layout.toast_layout, null);
    final ImageView toastIcon = (ImageView) toastLayout.findViewById(R.id.toast_icon);
    final TextView toastTextView = (TextView) toastLayout.findViewById(R.id.toast_text);
    Drawable drawableFrame;

    if (shouldTint)
        drawableFrame = ToastyUtils.tint9PatchDrawableFrame(context, tintColor);
    else
        drawableFrame = ToastyUtils.getDrawable(context, R.drawable.toast_frame);
    ToastyUtils.setBackground(toastLayout, drawableFrame);

    if (withIcon) {
        if (icon == null)
            throw new IllegalArgumentException("Avoid passing 'icon' as null if 'withIcon' is set to true");
        if (tintIcon)
            icon = ToastyUtils.tintIcon(icon, DEFAULT_TEXT_COLOR);
        ToastyUtils.setBackground(toastIcon, icon);
    } else {
        toastIcon.setVisibility(View.GONE);
    }

    toastTextView.setTextColor(DEFAULT_TEXT_COLOR);
    toastTextView.setText(message);
    toastTextView.setTypeface(currentTypeface);
    toastTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);

    currentToast.setView(toastLayout);
    currentToast.setDuration(duration);
    return currentToast;
}
 
開發者ID:LonelyMushroom,項目名稱:aarLibrary,代碼行數:37,代碼來源:Toasty.java

示例8: getMeasuredWidth

import android.widget.TextView; //導入方法依賴的package包/類
private int getMeasuredWidth(@NonNull Context context) {
    DisplayMetrics metrics = new DisplayMetrics();
    ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(metrics);

    int maxWidth = context.getResources().getDimensionPixelSize(R.dimen.popup_max_width);
    int minWidth = context.getResources().getDimensionPixelSize(R.dimen.popup_min_width);
    String longestText = "";
    for (PopupItem item : mAdapter.getItems()) {
        if (item.getTitle().length() > longestText.length())
            longestText = item.getTitle();
    }

    int padding = context.getResources().getDimensionPixelSize(R.dimen.content_margin);
    int iconSize = context.getResources().getDimensionPixelSize(R.dimen.icon_size_small);
    TextView textView = new TextView(context);
    textView.setLayoutParams(new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    textView.setTypeface(TypefaceHelper.getRegular(context));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getResources()
            .getDimension(R.dimen.text_content_subtitle));
    textView.setPadding(padding + iconSize + padding, 0, padding, 0);
    textView.setText(longestText);

    int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(metrics.widthPixels, View.MeasureSpec.AT_MOST);
    int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    textView.measure(widthMeasureSpec, heightMeasureSpec);

    int measuredWidth = textView.getMeasuredWidth() + padding;
    if (measuredWidth <= minWidth) {
        return minWidth;
    }

    if (measuredWidth >= minWidth && measuredWidth <= maxWidth) {
        return measuredWidth;
    }
    return maxWidth;
}
 
開發者ID:danimahardhika,項目名稱:wallpaperboard,代碼行數:38,代碼來源:Popup.java

示例9: onCreate

import android.widget.TextView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.bloodtype);
	
	prefs = this.getSharedPreferences("BloodType", Context.MODE_PRIVATE);
	
	strAndroidInfo = prefs.getString("BloodVal", "");
	inPrefConv = Integer.parseInt(strAndroidInfo);
	
	tvG = (TextView) findViewById(R.id.tvGiveTo);
	tvR = (TextView) findViewById(R.id.tvReceiveFrom);
	
	tvB = (TextView) findViewById(R.id.tvBloodDetail);
	tvB.setText(strBloodType[inPrefConv]);
	
	tvD = (TextView) findViewById(R.id.tvData);
	tvD.setTypeface(Typeface.createFromAsset(BloodType.this.getAssets(), "fonts/gbold.otf"));
	
	tvA = (TextView) findViewById(R.id.tvGive);
	tvC = (TextView) findViewById(R.id.tvReceive);
	
	animAnticipateOvershoot = AnimationUtils.loadAnimation(this, R.anim.overshoot);
	tvB.startAnimation(animAnticipateOvershoot);
	animAnticipateOvershootX = AnimationUtils.loadAnimation(this, R.anim.overshootx);
	tvC.startAnimation(animAnticipateOvershootX);
	tvA.startAnimation(animAnticipateOvershootX);
	
	//Handler handler = new Handler();
       //handler.postDelayed(task, 1000);
	
	PerformBloodCheck(inPrefConv);
	
	getActionBar().setDisplayHomeAsUpEnabled(true);
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:36,代碼來源:BloodType.java

示例10: init

import android.widget.TextView; //導入方法依賴的package包/類
private void init(Context context) {
    speedTextColor = ContextCompat.getColor(context, R.color.green);
    unitTextColor = ContextCompat.getColor(context, R.color.green);
    final View rootView = LayoutInflater.from(context).inflate(R.layout.digit_speed_view, this, true);
    mainLayout = (RelativeLayout) rootView.findViewById(R.id.digit_speed_main);
    mSpeedTextView = (TextView) rootView.findViewById(R.id.digit_speed);
    mSpeedBgTextView = (TextView) rootView.findViewById(R.id.digit_speed_bg);
    mSpeedUnitTextView = (TextView) rootView.findViewById(R.id.digit_speed_unit);
    Typeface tf = Typeface.createFromAsset(getResources().getAssets(), "fonts/digital-7_mono.ttf");
    mSpeedTextView.setTypeface(tf);
    mSpeedBgTextView.setTypeface(tf);
    mSpeedUnitTextView.setTypeface(tf);
}
 
開發者ID:capur16,項目名稱:DigitSpeedView,代碼行數:14,代碼來源:DigitSpeedView.java

示例11: ItemHolder

import android.widget.TextView; //導入方法依賴的package包/類
public ItemHolder(View itemView) {
    super(itemView);
    mPlaylistName = (TextView) itemView.findViewById(R.id.gridViewTitleText);
    mPlaylistName.setTypeface(TypefaceHelper.getTypeface(itemView.getContext().getApplicationContext(), TypefaceHelper.FUTURA_BOOK));

    mOverFlow = (ImageView) itemView.findViewById(R.id.overflow);
    mOverFlow.setOnClickListener(this);
    itemView.setOnClickListener(this);
}
 
開發者ID:reyanshmishra,項目名稱:Rey-MusicPlayer,代碼行數:10,代碼來源:PlaylistAdapter.java

示例12: ViewHolder

import android.widget.TextView; //導入方法依賴的package包/類
ViewHolder(View layout) {
    super(layout);

    eelativeLayout=(RelativeLayout)layout.findViewById(R.id.eelativeLayout);
    soraName = (TextView) layout.findViewById(R.id.textView5);
    ayaCount = (TextView) layout.findViewById(R.id.textView6);
    pageNumbers = (TextView) layout.findViewById(R.id.textView7);
    number = (TextView) layout.findViewById(R.id.textView4);
    soraName.setTypeface(customFont);
    ayaCount.setTypeface(customFont);
    pageNumbers.setTypeface(customFont);

}
 
開發者ID:fekracomputers,項目名稱:QuranAndroid,代碼行數:14,代碼來源:PartShowAdapter.java

示例13: ViewHolder

import android.widget.TextView; //導入方法依賴的package包/類
public ViewHolder(View itemView) {
    super(itemView);
    Typeface tf = Typeface.createFromAsset(context.getAssets(), "fonts/simple.otf");
    title = (TextView) itemView.findViewById(R.id.textView14);
    title.setTypeface(tf);
    ID = (TextView) itemView.findViewById(R.id.hidden);
    counter = (TextView) itemView.findViewById(R.id.textView16);
}
 
開發者ID:fekracomputers,項目名稱:MuslimMateAndroid,代碼行數:9,代碼來源:AzkarAdapter.java

示例14: applyFontForToolbarTitle

import android.widget.TextView; //導入方法依賴的package包/類
public static void applyFontForToolbarTitle(Activity context) {
    Toolbar toolbar = context.findViewById(R.id.toolbar);
    for (int i = 0; i < toolbar.getChildCount(); i++) {
        View view = toolbar.getChildAt(i);
        if (view instanceof TextView) {
            TextView tv = (TextView) view;

            if (tv.getText().equals(toolbar.getTitle())) {
                tv.setTypeface(TypefaceHelper.getTypeface(context, TypefaceHelper.FUTURA_BOLD));
                break;
            }
        }
    }
}
 
開發者ID:reyanshmishra,項目名稱:Rey-MusicPlayer,代碼行數:15,代碼來源:MusicUtils.java

示例15: updateTabStyles

import android.widget.TextView; //導入方法依賴的package包/類
private void updateTabStyles() {

        for (int i = 0; i < tabCount; i++) {
            View v = tabsContainer.getChildAt(i);
            if (selectedPosition == i) {
                v.setBackgroundResource(0);
            } else {
                v.setBackgroundResource(tabBackgroundResId);
            }

            if (v.findViewById(R.id.tv_content) instanceof TextView) {

                TextView tab = (TextView) v.findViewById(R.id.tv_content);
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
                tab.setTypeface(tabTypeface, tabTypefaceStyle);
                tab.setTextColor(tabTextColor);
//                Drawable rightDrawable = getResources().getDrawable(R.drawable.bg_msg);
//                int tvWidth = (int) tab.getPaint().measureText(tab.getText().toString() + "");
//                Log.d("tvlog", "rightDrawable.getMinimumWidth()=" + rightDrawable.getMinimumWidth() + ",rightDrawable.getMinimumHeight()=" + rightDrawable.getMinimumHeight());
//                Log.d("tvlog", "tab.getMeasuredWidth()="+tab.getMeasuredWidth()+",tvWidth="+tvWidth);
//
//                rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight());
//                tab.setCompoundDrawables(null, null, rightDrawable, null);

                // 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));
//                    }
//                }
                if (i == selectedPosition) {
                    tab.setTextColor(selectedTabTextColor);
                }
            }
        }

    }
 
開發者ID:q805699513,項目名稱:PagerSlidingTabStrip,代碼行數:41,代碼來源:PagerSlidingTabStrip.java


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