Android TextView underlined, underline, simple to use Marquee

I am a beginner Andrews, white one, I hope to write a blog method consolidate skills already learned, could not speak, hope you forgive me!

Not directly on the ink renderings
Here Insert Picture Description

TextView underlined and underlined

xml file (in the same or underline have a id on the line)

<TextView
        android:id="@+id/txv"
        android:text="中划线、下划线"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

java file

txv.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);   //中划线

txv.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);     //下划线

TextView Marquee (just set in the xml file)

Precautions

  1. TextView text length must be greater than the width of the control
  2. Line display TextView android: singleLine = "true"
  3. TextView need to get the focus android: focusable = "true" android: focusableInTouchMode = "true"
 <TextView
        android:id="@+id/txvpmd"
        android:layout_height="wrap_content"
        android:layout_width="100dp"
        android:textSize="20sp"
        android:layout_marginTop="20dp"
        android:text="两次返回键才返回!两次返回键才返回!两次返回键才返回! "
        
        android:singleLine="true"
        android:ellipsize="marquee"
        android:marqueeRepeatLimit="marquee_forever" 
        android:focusable="true"
        android:focusableInTouchMode="true"/>
ellipsize property supplement

When the text display no less than:
Android: ellipsize = "Marquee" marquee effect
android: ellipsize = "end" at the end of the ellipsis
android: ellipsize = "start" at the beginning of the ellipsis
android: ellipsize = "middle" in the middle of the ellipsis

Marquee cycles supplement

android: marqueeRepeatLimit = "marquee_forever" represents ticker stop the run -

Released six original articles · won praise 5 · Views 242

Guess you like

Origin blog.csdn.net/qq_44720366/article/details/103492957