Android知识点textview的属性

1. TextView加横线的属性

例如:加下划线和价钱上加横线


底部加横线是
textview.getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG );

textview.getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG  |Paint.ANTI_ALIAS_FLAG);加上后面的属性字体更清晰一些

中间加横线是:
textview.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG );这个属性的字体有点模糊不清
 

textview.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG |Paint.ANTI_ALIAS_FLAG);加上这个属性,字体更清晰一些

参考文章:http://blog.csdn.net/aaawqqq/article/details/27861017

==================================================

2. TextView在代码中动态添加图片

Drawable shareMip= getResources().getDrawable(R.mipmap.icon_support);
shareMip.setBounds(0, 0, shareMip.getMinimumWidth(), shareMip.getMinimumHeight());
textviewTitle.setCompoundDrawables(shareMip, null, null, null);

同样,参考另一种函数

public void setCompoundDrawablesWithIntrinsicBounds(Drawable left,Drawable top,Drawable right,Drawable bottom)

Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text. Use null if you do not want a Drawable there. The Drawables' bounds will be set to their intrinsic bounds.


例如:

TextView mTextView = (TextView) linearLayout.findViewById(R.id.tv_select_item); 
mTextView.setCompoundDrawables(drawable,null,null,null);//设置TextView的drawableleft 
mTextView.setCompoundDrawablePadding(10);//设置图片和text之间的间距 
mTextView.setText(mSelfSelect[i]); 
 // 添加到屏幕布局 
LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT); 
mLayout.addView(linearLayout, layoutParams);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值