android.widget.TextView.setIncludeFontPadding()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(308)

本文整理了Java中android.widget.TextView.setIncludeFontPadding()方法的一些代码示例,展示了TextView.setIncludeFontPadding()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.setIncludeFontPadding()方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:setIncludeFontPadding

TextView.setIncludeFontPadding介绍

暂无

代码示例

代码示例来源:origin: TheFinestArtist/FinestWebView-Android

protected void updateChildTextView(ViewGroup viewGroup) {
 if (viewGroup == null || viewGroup.getChildCount() == 0) {
  return;
 }
 for (int i = 0; i < viewGroup.getChildCount(); i++) {
  View view = viewGroup.getChildAt(i);
  if (view instanceof TextView) {
   TextView textView = (TextView) view;
   textView.setTextColor(titleColor);
   textView.setTypeface(TypefaceHelper.get(this, titleFont));
   textView.setLineSpacing(0, 1.1f);
   textView.setIncludeFontPadding(false);
  }
  if (view instanceof ViewGroup) {
   updateChildTextView((ViewGroup) view);
  }
 }
}

代码示例来源:origin: jaydenxiao2016/AndroidFire

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();
}

代码示例来源:origin: rey5137/material

v.setIncludeFontPadding(a.getBoolean(attr, true));

代码示例来源:origin: venshine/GoodView

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();
}

代码示例来源:origin: darkskygit/VirtualApp

@Override
public void setIncludeFontPadding(boolean includepad) {
  super.setIncludeFontPadding(includepad);
  mIncludeFontPadding = includepad;
}

代码示例来源:origin: bzsome/VirtualApp-x326

@Override
public void setIncludeFontPadding(boolean includepad) {
  super.setIncludeFontPadding(includepad);
  mIncludeFontPadding = includepad;
}

代码示例来源:origin: stackoverflow.com

private void setGravityAndText(TextView textView,String text){
  if(text.length()>24){
    textView.setIncludeFontPadding(true);
    textView.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP);
  }
  else {
    textView.setIncludeFontPadding(false);
    textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
  }
  textView.setText(text);

}

代码示例来源:origin: Tencent/RapidView

public void run(RapidParserObject object, Object view, Var value) {
    ((TextView)view).setIncludeFontPadding(value.getBoolean());
  }
}

代码示例来源:origin: 296777513/pedometer

tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
tv.setSingleLine();
tv.setIncludeFontPadding(false);
LinearLayout.LayoutParams lpTv = new LinearLayout.LayoutParams(
    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

代码示例来源:origin: fengmaolian/LoginAndShare

tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
tv.setSingleLine();
tv.setIncludeFontPadding(false);
LayoutParams lpTv = new LayoutParams(
    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

代码示例来源:origin: albert-lii/ImageViewer

private void initView() {
  viewPager = new PreviewViewPager(container.getContext());
  viewPager.setOffscreenPageLimit(1);
  viewPager.addOnPageChangeListener(this);
  container.addView(viewPager, new FrameLayout.LayoutParams(
      FrameLayout.LayoutParams.MATCH_PARENT,
      FrameLayout.LayoutParams.MATCH_PARENT));
  indexView = new TextView(container.getContext());
  FrameLayout.LayoutParams textParams = new FrameLayout.LayoutParams(
      FrameLayout.LayoutParams.WRAP_CONTENT,
      FrameLayout.LayoutParams.WRAP_CONTENT);
  textParams.setMargins(0,
      dp2px(container.getContext(), 5),
      0,
      0);
  textParams.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
  indexView.setLayoutParams(textParams);
  indexView.setIncludeFontPadding(false);
  indexView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
  indexView.setTextColor(Color.WHITE);
  indexView.setVisibility(View.GONE);
  container.addView(indexView);
}

代码示例来源:origin: venshine/WheelView

mText.setEllipsize(TextUtils.TruncateAt.END);
mText.setSingleLine();
mText.setIncludeFontPadding(false);
mText.setGravity(Gravity.CENTER);
mText.setTextColor(Color.BLACK);

代码示例来源:origin: stackoverflow.com

private static void setLeading(TextView view, int step, int leading) {
  // This is to make the behavior more deterministic: remove extra top/bottom padding
  view.setIncludeFontPadding(false);

  // Get font metrics and calculate required inter-line extra
  Paint.FontMetricsInt metrics = view.getPaint().getFontMetricsInt();
  final int extra = leading - metrics.descent + metrics.ascent;
  view.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;

  view.setPadding(view.getPaddingLeft(), view.getPaddingTop() + alignTopExtra, view.getPaddingRight(), view.getPaddingBottom() + alignBottomExtra);
}

代码示例来源:origin: Actinarium/Aligned

int lastLineDescent) {
view.setIncludeFontPadding(false);

代码示例来源:origin: jelic98/dynamico

textView.setIncludeFontPadding(attributes.getBoolean("includeFontPadding"));

相关文章

TextView类方法