当前位置: 首页>>代码示例>>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;未经允许,请勿转载。