本文整理了Java中android.widget.TextView.setLineSpacing()
方法的一些代码示例,展示了TextView.setLineSpacing()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.setLineSpacing()
方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:setLineSpacing
暂无
代码示例来源:origin: ZieIony/Carbon
@Override
public void setLineSpacing(float add, float mult) {
super.setLineSpacing(add, mult);
spacingMult = mult;
spacingAdd = add;
}
代码示例来源: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: lygttpod/SuperTextView
/**
* 初始化中下textView
*/
private void initCenterBottomText() {
if (centerBottomTextView == null) {
if (centerBottomTVParams == null) {
centerBottomTVParams = getParams(centerBottomTVParams);
}
centerBottomTVParams.addRule(RelativeLayout.CENTER_VERTICAL, TRUE);
centerBottomTVParams.addRule(RelativeLayout.CENTER_IN_PARENT, TRUE);
centerBottomTVParams.addRule(BELOW, R.id.cCenterBaseLineId);
centerBottomTVParams.setMargins(mCenterViewPaddingLeft, 0, mCenterViewPaddingRight, 0);
centerBottomTextView = initText(centerBottomTextView, centerBottomTVParams, R.id.cCenterBottomTextId, mCenterBottomTextColor, mCenterBottomTextSize);
centerBottomTextView.setText(mCenterBottomTextString);
centerBottomTextView.setLineSpacing(mCenterTextViewLineSpacingExtra, 1.0f);
setTextViewGravity(centerBottomTextView, mCenterTextViewGravity);
}
}
代码示例来源:origin: lygttpod/SuperTextView
/**
* 初始化右上textView
*/
private void initRightTopText() {
if (rightTopTextView == null) {
if (rightTopTVParams == null) {
rightTopTVParams = getParams(rightTopTVParams);
}
rightTopTVParams.addRule(RelativeLayout.CENTER_VERTICAL, TRUE);
rightTopTVParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, TRUE);
rightTopTVParams.addRule(ABOVE, R.id.cCenterBaseLineId);
rightTopTVParams.addRule(RelativeLayout.LEFT_OF, R.id.cRightImageViewId);
rightTopTVParams.setMargins(mRightViewPaddingLeft, 0, mRightViewPaddingRight, 0);
rightTopTextView = initText(rightTopTextView, rightTopTVParams, R.id.cRightTopTextId, mRightTopTextColor, mRightTopTextSize);
rightTopTextView.setText(mRightTopTextString);
rightTopTextView.setLineSpacing(mRightTextViewLineSpacingExtra, 1.0f);
setTextViewGravity(rightTopTextView, mRightTextViewGravity);
}
}
代码示例来源:origin: H07000223/FlycoDialog_Master
mTvContent.setTextColor(mContentTextColor);
mTvContent.setTextSize(TypedValue.COMPLEX_UNIT_SP, mContentTextSize);
mTvContent.setLineSpacing(0, 1.3f);
代码示例来源:origin: lygttpod/SuperTextView
/**
* 初始化右下textView
*/
private void initRightBottomText() {
if (rightBottomTextView == null) {
if (rightBottomTVParams == null) {
rightBottomTVParams = getParams(rightBottomTVParams);
}
rightBottomTVParams.addRule(RelativeLayout.CENTER_VERTICAL, TRUE);
rightBottomTVParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, TRUE);
rightBottomTVParams.addRule(BELOW, R.id.cCenterBaseLineId);
rightBottomTVParams.addRule(RelativeLayout.LEFT_OF, R.id.cRightImageViewId);
rightBottomTVParams.setMargins(mRightViewPaddingLeft, 0, mRightViewPaddingRight, 0);
rightBottomTextView = initText(rightBottomTextView, rightBottomTVParams, R.id.cRightBottomTextId, mRightBottomTextColor, mRightBottomTextSize);
rightBottomTextView.setText(mRightBottomTextString);
rightBottomTextView.setLineSpacing(mRightTextViewLineSpacingExtra, 1.0f);
setTextViewGravity(rightBottomTextView, mRightTextViewGravity);
}
}
代码示例来源:origin: lygttpod/SuperTextView
/**
* 初始化中上textView
*/
private void initCenterTopText() {
if (centerTopTextView == null) {
if (centerTopTVParams == null) {
centerTopTVParams = getParams(centerTopTVParams);
}
centerTopTVParams.addRule(RelativeLayout.CENTER_VERTICAL, TRUE);
centerTopTVParams.addRule(RelativeLayout.CENTER_IN_PARENT, TRUE);
centerTopTVParams.addRule(ABOVE, R.id.cCenterBaseLineId);
centerTopTVParams.setMargins(mCenterViewPaddingLeft, 0, mCenterViewPaddingRight, 0);
centerTopTextView = initText(centerTopTextView, centerTopTVParams, R.id.cCenterTopTextId, mCenterTopTextColor, mCenterTopTextSize);
centerTopTextView.setText(mCenterTopTextString);
centerTopTextView.setLineSpacing(mCenterTextViewLineSpacingExtra, 1.0f);
setTextViewGravity(centerTopTextView, mCenterTextViewGravity);
}
}
代码示例来源:origin: lygttpod/SuperTextView
rightTextView.setText(mRightTextString);
rightTextView.setLineSpacing(mRightTextViewLineSpacingExtra, 1.0f);
setTextViewGravity(rightTextView, mRightTextViewGravity);
if (mRightViewIsClickable) {
代码示例来源:origin: lygttpod/SuperTextView
/**
* 初始化左边textView
*/
private void initLeftText() {
if (leftTextView == null) {
if (leftTVParams == null) {
leftTVParams = getParams(leftTVParams);
}
leftTVParams.addRule(CENTER_VERTICAL, TRUE);
leftTVParams.addRule(RIGHT_OF, R.id.cLeftImageViewId);
leftTVParams.setMargins(mLeftViewPaddingLeft, 0, mLeftViewPaddingRight, 0);
leftTextView = initText(leftTextView, leftTVParams, R.id.cLeftTextId, mLeftTextColor, mLeftTextSize);
leftTextView.setText(mLeftTextString);
leftTextView.setLineSpacing(mLeftTextViewLineSpacingExtra, 1.0f);
setTextViewGravity(leftTextView, mLeftTextViewGravity);
if (mLeftViewIsClickable) {
leftTextView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (onCommonTextViewClickListener != null) {
onCommonTextViewClickListener.onLeftViewClick();
}
}
});
}
}
setDrawable(leftTextView, mLeft_drawableLeft, mLeft_drawableTop, mLeft_drawableRight, mLeft_drawableBottom, mLeftIconDrawablePadding);
}
代码示例来源:origin: lygttpod/SuperTextView
centerTextView.setLineSpacing(mCenterTextViewLineSpacingExtra, 1.0f);
代码示例来源:origin: hidroh/materialistic
@CallSuper
protected void bind(final VH holder, final Item item) {
if (item == null) {
return;
}
highlightUserItem(holder, item);
decorateDead(holder, item);
holder.mContentTextView.setLineSpacing(0f, mLineHeight);
AppUtils.setTextWithLinks(holder.mContentTextView, item.getDisplayedText());
Integer lineCount = mLineCounted.get(item.getId());
if (lineCount != null && lineCount > 0) {
toggleCollapsibleContent(holder, item, lineCount);
} else {
holder.mContentTextView.post(() -> {
if (mContext == null) {
return;
}
int count = holder.mContentTextView.getLineCount();
mLineCounted.put(item.getId(), count);
toggleCollapsibleContent(holder, item, count);
});
}
bindActions(holder, item);
}
代码示例来源:origin: sendtion/XRichText
/**
* 生成文本输入框
*/
public TextView createTextView(String hint, int paddingTop) {
TextView textView = (TextView) inflater.inflate(R.layout.rich_textview, null);
textView.setTag(viewTagIndex++);
textView.setPadding(editNormalPadding, paddingTop, editNormalPadding, paddingTop);
textView.setHint(hint);
//textView.setTextSize(getResources().getDimensionPixelSize(R.dimen.text_size_16));
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, rtTextSize);
textView.setLineSpacing(rtTextLineSpace, 1.0f);
textView.setTextColor(rtTextColor);
return textView;
}
代码示例来源:origin: Sonelli/juicessh-performancemonitor
/**
* Override the set line spacing to update our internal reference values
*/
@Override
public void setLineSpacing(float add, float mult) {
super.setLineSpacing(add, mult);
mSpacingMult = mult;
mSpacingAdd = add;
}
代码示例来源:origin: darkskygit/VirtualApp
@Override
public void setLineSpacing(float add, float mult) {
super.setLineSpacing(add, mult);
mLineSpacingAdd = add;
mLineSpacingMult = mult;
}
代码示例来源:origin: bzsome/VirtualApp-x326
@Override
public void setLineSpacing(float add, float mult) {
super.setLineSpacing(add, mult);
mLineSpacingAdd = add;
mLineSpacingMult = mult;
}
代码示例来源:origin: chenjishi/SlideActivity
@Override
public Object instantiateItem(ViewGroup container, int position) {
ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT);
TextView v = new TextView(ViewPagerActivity.this);
v.setTextColor(0xFF333333);
v.setText(R.string.description);
v.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);
v.setLineSpacing(4 * density, 1);
int padding = (int) (density * 8 + .5);
v.setPadding(padding, padding, padding, padding);
container.addView(v, lp);
return v;
}
代码示例来源:origin: Tencent/RapidView
public void run(RapidParserObject object, Object view, Var value) {
((TextView)view).setLineSpacing(0, value.getFloat());
}
}
代码示例来源:origin: Tencent/RapidView
public void run(RapidParserObject object, Object view, Var value) {
((TextView)view).setLineSpacing(ViewUtils.dip2px(((View) view).getContext(), value.getFloat()), 0);
}
}
代码示例来源:origin: KCrason/HighPerformanceFriendsCircle
private TextView makeContentTextView(SpannableStringBuilder content, int index) {
TextView textView = new TextView(getContext());
textView.setTextColor(ContextCompat.getColor(getContext(), R.color.base_333333));
textView.setBackgroundResource(R.drawable.selector_view_name_state);
textView.setTextSize(16f);
textView.setLineSpacing(mCommentVerticalSpace, 1f);
textView.setText(content);
textView.setMovementMethod(new TextMovementMethod());
addOnItemClickPopupMenuListener(textView, index, TranslationState.START);
return textView;
}
代码示例来源:origin: stackoverflow.com
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final TextView tv = new TextView(this);
tv.setLineSpacing(2, 1); // UPDATE HERE
setContentView(tv);
tv.setText("Lines:\n", BufferType.EDITABLE);
appendLine(tv.getEditableText(), "Line 1 = 40\n", 40);
appendLine(tv.getEditableText(), "Line 2 = 30\n", 30);
appendLine(tv.getEditableText(), "Line 3 = 20\n", 20);
appendLine(tv.getEditableText(), "Line 4 = 10\n", 10);
}
内容来源于网络,如有侵权,请联系作者删除!