TextView加下划线
tvTest.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG ); //下划线 tvTest.getPaint().setAntiAlias(true);//抗锯齿
EditText组件drawableLeft属性设置的图片和hint设置的文字之间的距离
<EditText android:id="@+id/tel_num" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="25dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:drawablePadding="8dp" android:drawableLeft="@drawable/phone" android:hint="请输入手机号码" />
- 代码设置 :
// void android.widget.TextView.setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom)
tv_xxx.setCompoundDrawables(null, xxxApplication.getContext().getResources().getDrawable(R.mipmap.xxx), null, null);
tv_xxx.setCompoundDrawablePadding(20);
- 代码设置 :
行间距
android:lineSpacingExtra="2dp"
setTextColor()的参数设置
setTextColor(0xFF0000FF);//0xFF0000FF是int类型的数据,分组一下0x|FF|0000FF,0x是代表颜色整数的标记,ff是表示透明度,0000FF表示颜色,注意:这里0xFF0000FF必须是8个的颜色表示,不接受0000FF这种6个的颜色表示。 另外还可以使用系统自带的颜色类setTextColor(android.graphics.Color.BLUE); 还有就是使用资源文件进行设置setTextColor(this.getResources().getColor(R.color.blue));//通过获得资源文件进行设置。根据不同的情况R.color.blue也可以是R.string.blue或者R.drawable.blue,当然前提是需要在相应的配置文件里做相应的配置,如: <color name="blue">#0000FF</color> <drawable name="blue">#0000FF</drawable> <string name="blue">#0000FF</string>
改变背景图片
tv_title_select1.setBackgroundResource(R.mipmap.right_btn_nor);字符串截取 :
TextView、EditText
最新推荐文章于 2022-03-19 21:37:02 发布