TextView 常用摘要
1、代码中设置drawableTop
TextView textView = new TextView(getActivity()); Drawable drawable = getResources().getDrawable(R.drawable.home_1); drawable.setBounds(0, 0, drawable.getMinimumWidth(),drawable.getMinimumHeight()); textView.setCompoundDrawables(null, drawable, null, null); textView.setCompoundDrawablePadding(10);//设置drawablepadding
2、走马灯效果
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#ffffff" android:clickable="true" android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" android:freezesText="true" android:marqueeRepeatLimit="marquee_forever" android:padding="10dip" android:selectAllOnFocus="true" android:singleLine="true" android:text="123456789987565165465454" android:textColor="#000000" android:textSize="22sp" > </TextView >
3、划线
//上划线 setText(Html.fromHtml("<o>"+要输入的东西+"</o>")); //下划线 1、setText(Html.fromHtml("<u>"+要输入的东西+"</u>"));
2、tvTest.getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG ); //下划线
tvTest.getPaint().setAntiAlias(true);//抗锯齿
//中划线
textview.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG);
4、中文字体加粗
TextView tv = (TextView)findViewById(R.id.tv); TextPaint tp = tv.getPaint(); tp.setFakeBoldText(true);