Android TextView的設置


 

設置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的行間距(非行高)

  1. android:lineSpacingExtra
    設置行間距,如”3dp”。

  2.  

    android:lineSpacingMultiplier
    設置行間距的倍數,如”1.5″。


 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM