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


Java TextView.setIncludeFontPadding方法代碼示例

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


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

示例1: setupTextView

import android.widget.TextView; //導入方法依賴的package包/類
private void setupTextView(final TextView textView, final int leading, final int step) {
    // This is to make the behavior more deterministic: remove extra top/bottom padding
    textView.setIncludeFontPadding(false);

    // Get font metrics and calculate required inter-line extra
    Paint.FontMetricsInt metrics = textView.getPaint().getFontMetricsInt();
    final int extra = leading - metrics.descent + metrics.ascent;
    textView.setLineSpacing(extra, 1);

    // Determine minimum required top extra so that the view lands on the grid
    final int alignTopExtra = (step + metrics.ascent % step) % step;
    // Determine minimum required bottom extra so that view bounds are aligned with the grid
    final int alignBottomExtra = (step - metrics.descent % step) % step;

    textView.setPadding(textView.getPaddingLeft(), textView.getPaddingTop() + alignTopExtra,
            textView.getPaddingRight(), textView.getPaddingBottom() + alignBottomExtra);
}
 
開發者ID:lurbas,項目名稱:ListItemView,代碼行數:18,代碼來源:ListItemView.java

示例2: init

import android.widget.TextView; //導入方法依賴的package包/類
/**
 * 初始化
 */
private void init() {
    LinearLayout layout = new LinearLayout(getContext());
    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, WheelUtils.dip2px(getContext(),
            WheelConstants
                    .WHEEL_ITEM_HEIGHT));
    layout.setOrientation(LinearLayout.HORIZONTAL);
    layout.setPadding(WheelConstants.WHEEL_ITEM_PADDING, WheelConstants.WHEEL_ITEM_PADDING, WheelConstants
            .WHEEL_ITEM_PADDING, WheelConstants.WHEEL_ITEM_PADDING);
    layout.setGravity(Gravity.CENTER);
    addView(layout, layoutParams);

    // 圖片
    mImage = new ImageView(getContext());
    mImage.setTag(WheelConstants.WHEEL_ITEM_IMAGE_TAG);
    mImage.setVisibility(View.GONE);
    LayoutParams imageParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    imageParams.rightMargin = WheelConstants.WHEEL_ITEM_MARGIN;
    layout.addView(mImage, imageParams);

    // 文本
    mText = new TextView(getContext());
    mText.setTag(WheelConstants.WHEEL_ITEM_TEXT_TAG);
    mText.setEllipsize(TextUtils.TruncateAt.END);
    mText.setSingleLine();
    mText.setIncludeFontPadding(false);
    mText.setGravity(Gravity.CENTER);
    mText.setTextColor(Color.BLACK);
    LayoutParams textParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    layout.addView(mText, textParams);
}
 
開發者ID:zuoweitan,項目名稱:Hitalk,代碼行數:34,代碼來源:WheelItem.java

示例3: addHintIcon

import android.widget.TextView; //導入方法依賴的package包/類
public void addHintIcon(int drawableId)
{
	if (this.mHintIconArray.indexOfKey(drawableId) == -1)
	{
		this.mHintIconArray.put(drawableId, drawableId);
		
		TextView tv = new TextView(mContext);
		tv.setTag(drawableId);
		tv.setGravity(Gravity.CENTER);
		ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
				ViewGroup.LayoutParams.WRAP_CONTENT);
		tv.setLayoutParams(lp);
		tv.setBackgroundResource(drawableId);
		tv.setIncludeFontPadding(false);
		
		this.mHintIcons.addView(tv);
	}
}
 
開發者ID:benniaobuguai,項目名稱:android-project-gallery,代碼行數:19,代碼來源:XPreference.java

示例4: init

import android.widget.TextView; //導入方法依賴的package包/類
private void init(Context context) {
    setOrientation(LinearLayout.HORIZONTAL);
    int paddingTopBottom = ConvertUtils.toPx(context, ITEM_PADDING_TOP_BOTTOM);
    int paddingLeftRight = ConvertUtils.toPx(context, ITEM_PADDING_LEFT_RIGHT);
    setPadding(paddingLeftRight, paddingTopBottom, paddingLeftRight, paddingTopBottom);
    setGravity(Gravity.CENTER);
    int height = ConvertUtils.toPx(context, ITEM_HEIGHT);
    // fixed: 17-1-8 #79 安卓4.x兼容問題,java.lang.ClassCastException……onMeasure……
    setLayoutParams(new AbsListView.LayoutParams(MATCH_PARENT, height));

    imageView = new ImageView(getContext());
    imageView.setTag(ITEM_TAG_IMAGE);
    imageView.setVisibility(View.GONE);
    LayoutParams imageParams = new LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
    imageParams.rightMargin = ConvertUtils.toPx(context, ITEM_MARGIN);
    addView(imageView, imageParams);

    textView = new TextView(getContext());
    textView.setTag(ITEM_TAG_TEXT);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setSingleLine(true);
    textView.setIncludeFontPadding(false);
    textView.setGravity(Gravity.CENTER);
    textView.setTextColor(Color.BLACK);
    LayoutParams textParams = new LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
    addView(textView, textParams);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:28,代碼來源:WheelListView.java

示例5: initView

import android.widget.TextView; //導入方法依賴的package包/類
private void initView() {
    RelativeLayout layout = new RelativeLayout(mContext);
    RelativeLayout.LayoutParams params =
            new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
                    RelativeLayout.LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.CENTER_HORIZONTAL);
    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);

    mGood = new TextView(mContext);
    mGood.setIncludeFontPadding(false);
    mGood.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mTextSize);
    mGood.setTextColor(ContextCompat.getColor(mContext, mTextColor));
    mGood.setText(mText);
    mGood.setLayoutParams(params);
    layout.addView(mGood);
    setContentView(layout);

    int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    mGood.measure(w, h);
    setWidth(mGood.getMeasuredWidth());
    setHeight(mDistance + mGood.getMeasuredHeight());
    setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    setFocusable(false);
    setTouchable(false);
    setOutsideTouchable(false);

    mAnimationSet = createAnimation();
}
 
開發者ID:wp521,項目名稱:MyFire,代碼行數:30,代碼來源:GoodView.java

示例6: getView

import android.widget.TextView; //導入方法依賴的package包/類
private LinearLayout getView(int position, OnClickListener ocL, Context context) {
	Bitmap logo;
	String label;
	OnClickListener listener;
	if (beans[position] instanceof Platform) {
		logo = getIcon((Platform) beans[position]);
		label = getName((Platform) beans[position]);
		listener = ocL;
	} else {
		logo = ((CustomerLogo) beans[position]).enableLogo;
		label = ((CustomerLogo) beans[position]).label;
		listener = ocL;
	}

	LinearLayout ll = new LinearLayout(context);
	ll.setOrientation(LinearLayout.VERTICAL);

	ImageView iv = new ImageView(context);
	int dp_5 = com.mob.tools.utils.R.dipToPx(context, 5);
	iv.setPadding(dp_5, dp_5, dp_5, dp_5);
	iv.setScaleType(ScaleType.CENTER_INSIDE);
	LayoutParams lpIv = new LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpIv.setMargins(dp_5, dp_5, dp_5, dp_5);
	lpIv.gravity = Gravity.CENTER_HORIZONTAL;
	iv.setLayoutParams(lpIv);
	iv.setImageBitmap(logo);
	ll.addView(iv);

	TextView tv = new TextView(context);
	tv.setTextColor(0xff000000);
	tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
	tv.setSingleLine();
	tv.setIncludeFontPadding(false);
	LayoutParams lpTv = new LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpTv.gravity = Gravity.CENTER_HORIZONTAL;
	lpTv.weight = 1;
	lpTv.setMargins(dp_5, 0, dp_5, dp_5);
	tv.setLayoutParams(lpTv);
	tv.setText(label);
	ll.addView(tv);
	ll.setOnClickListener(listener);

	return ll;
}
 
開發者ID:liupengandroid,項目名稱:ywApplication,代碼行數:47,代碼來源:PlatformGridView.java

示例7: initView

import android.widget.TextView; //導入方法依賴的package包/類
private void initView() {
    RelativeLayout layout = new RelativeLayout(mContext);
    RelativeLayout.LayoutParams params =
            new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
                    RelativeLayout.LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.CENTER_HORIZONTAL);
    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);

    mGood = new TextView(mContext);
    mGood.setIncludeFontPadding(false);
    mGood.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mTextSize);
    mGood.setTextColor(mTextColor);
    mGood.setText(mText);
    mGood.setLayoutParams(params);
    layout.addView(mGood);
    setContentView(layout);

    int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    mGood.measure(w, h);
    setWidth(mGood.getMeasuredWidth());
    setHeight(mDistance + mGood.getMeasuredHeight());
    setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    setFocusable(false);
    setTouchable(false);
    setOutsideTouchable(false);

    mAnimationSet = createAnimation();
}
 
開發者ID:ruiqiao2017,項目名稱:Renrentou,代碼行數:30,代碼來源:GoodView.java

示例8: addTextTab

import android.widget.TextView; //導入方法依賴的package包/類
private void addTextTab(final int position, String title) {
    TextView tab = new TextView(getContext());
    tab.setText(title);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    tab.setIncludeFontPadding(false);

    TextView tab2 = new TextView(getContext());
    tab2.setText(title);
    tab2.setGravity(Gravity.CENTER);
    tab2.setSingleLine();
    tab2.setIncludeFontPadding(false);

    addTab(position, tab, tab2);
}
 
開發者ID:SavorGit,項目名稱:Hotspot-master-devp,代碼行數:16,代碼來源:PagerSlidingTabStrip.java

示例9: getView

import android.widget.TextView; //導入方法依賴的package包/類
private LinearLayout getView(int position, OnClickListener ocL, Context context) {
    Bitmap logo;
    String label;
    OnClickListener listener;
    if (this.beans[position] instanceof Platform) {
        logo = getIcon((Platform) this.beans[position]);
        label = getName((Platform) this.beans[position]);
        listener = ocL;
    } else {
        logo = ((CustomerLogo) this.beans[position]).enableLogo;
        label = ((CustomerLogo) this.beans[position]).label;
        listener = ocL;
    }
    LinearLayout ll = new LinearLayout(context);
    ll.setOrientation(1);
    ImageView iv = new ImageView(context);
    int dp_5 = R.dipToPx(context, 5);
    iv.setPadding(dp_5, dp_5, dp_5, dp_5);
    iv.setScaleType(ScaleType.CENTER_INSIDE);
    LayoutParams lpIv = new LayoutParams(-2, -2);
    lpIv.setMargins(dp_5, dp_5, dp_5, dp_5);
    lpIv.gravity = 1;
    iv.setLayoutParams(lpIv);
    iv.setImageBitmap(logo);
    ll.addView(iv);
    TextView tv = new TextView(context);
    tv.setTextColor(AbstractWheelTextAdapter.DEFAULT_TEXT_COLOR);
    tv.setTextSize(1, 14.0f);
    tv.setSingleLine();
    tv.setIncludeFontPadding(false);
    LayoutParams lpTv = new LayoutParams(-2, -2);
    lpTv.gravity = 1;
    lpTv.weight = 1.0f;
    lpTv.setMargins(dp_5, 0, dp_5, dp_5);
    tv.setLayoutParams(lpTv);
    tv.setText(label);
    ll.addView(tv);
    ll.setOnClickListener(listener);
    return ll;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:41,代碼來源:PlatformGridView.java

示例10: getView

import android.widget.TextView; //導入方法依賴的package包/類
private LinearLayout getView(int position, OnClickListener ocL, Context context) {
			Bitmap logo;
			String label;
			OnClickListener listener;
			if (beans[position] instanceof Platform) {
				logo = getIcon((Platform) beans[position]);
				label = getName((Platform) beans[position]);
				listener = ocL;
			} else {
				logo = ((CustomerLogo) beans[position]).logo;
				label = ((CustomerLogo) beans[position]).label;
				listener = ((CustomerLogo) beans[position]).listener;
			}

			LinearLayout ll = new LinearLayout(context);
			ll.setOrientation(LinearLayout.VERTICAL);

			ImageView iv = new ImageView(context);
			int dp_5 = cn.sharesdk.framework.utils.R.dipToPx(context, 5);
			iv.setPadding(dp_5, dp_5, dp_5, dp_5);
			iv.setScaleType(ScaleType.CENTER_INSIDE);
			LinearLayout.LayoutParams lpIv = new LinearLayout.LayoutParams(
					LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
			lpIv.setMargins(dp_5, dp_5, dp_5, dp_5);
			lpIv.gravity = Gravity.CENTER_HORIZONTAL;
			iv.setLayoutParams(lpIv);
			iv.setImageBitmap(logo);
			ll.addView(iv);

			TextView tv = new TextView(context);
//			tv.setTextColor(0x2A1E21);
			tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
			tv.setSingleLine();
			tv.setIncludeFontPadding(false);
			LinearLayout.LayoutParams lpTv = new LinearLayout.LayoutParams(
					LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
			lpTv.gravity = Gravity.CENTER_HORIZONTAL;
			lpTv.weight = 1;
			lpTv.setMargins(dp_5, 0, dp_5, dp_5);
			tv.setLayoutParams(lpTv);
			tv.setText(Html.fromHtml("<font color='black'>"+label+"</font>"));
			ll.addView(tv);
			ll.setOnClickListener(listener);

			return ll;
		}
 
開發者ID:SShineTeam,項目名稱:Huochexing12306,代碼行數:47,代碼來源:PlatformGridView.java


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