設置TextView文字的透明效果
1 //android:textColor="#50ff00ff"2 //在XML中使用顏色碼設置文本顏色,若要設置透明度,只須設置第一、二位數字即可。顏色碼的規則:透明度(2位)紅色(2位)綠色(2位)藍色(2位) 3 mTVText.setTextColor(Color.argb(50, 30, 255, 0));
2.TextView設置文本高亮顯示
textView.setText(R.string.app,BufferType.EDITABLE); Editable et = textView.getEditableText(); //設置背景色:new BackgroundColorSpan(Color.BLUE); et.setSpan(new ForegroundColorSpan(Color.CYAN), 5, 10, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
以上1、2實現的效果圖如下

3.TextView設置"跑馬燈"效果
<TextView android:id="@+id/testView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/app" 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:textColor="#50ff00ff" />
4:Android系統中設置TextView的行間距(非行高)
-
android:lineSpacingExtra
設置行間距,如”3dp”。 -
android:lineSpacingMultiplier
設置行間距的倍數,如”1.5″。
