设置保留小数点位数:
//DecimalFormat转换最简便
DecimalFormat df = new DecimalFormat("0.00");
String result = df.format(value);
//String.format打印最简便
String.format("%.2f", value);
代码中设置TextView的颜色:
text.setTextColor( )方法:
Color.parseColor("#bcbcbc");
getResources().getColor(R.color.my_color)
设置TextView有下划线:
textview.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
TextView实现文本自动滚动效果用:
写类ScrollTextView继承TextView,重写其中的isFocused()方法,return true;
然后在布局文件中添加以下设置。
android:singleLine="true"
然后在布局文件中添加以下设置。
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:scrollHorizontally="true"
android:marqueeRepeatLimit="marquee_forever"
android:maxEms="8"
持续更新中