Android_ Common UI controls _01_textview4_rollingsubtitles effects plus linked text

Source: Internet
Author: User

(1) Mainactivity.java

package com.example.android_textview_rollingsubtitles;import java.sql.wrapper;import  android.os.bundle;import android.app.activity;import android.text.html;import  android.text.textutils;import android.text.textutils.truncateat;import  android.text.method.linkmovementmethod;import android.view.menu;import android.widget.textview; public class mainactivity extends activity {    private  textview textview;     @Override     protected void  OnCreate (bundle savedinstancestate)  {        super.oncreate ( Savedinstancestate);         setcontentview (R.layout.activity_main);         textview = (TextView)  this.findviewbyid (R.id.textveiw );        string html =  "andRoid <font color= ' Blue ' ><a href= ' http://test.com ' >Linux</a></font>   System. Pacific Internet provides comprehensive service information for Android phone, including Android phone quotes, parameters, reviews, comparison ";         Charsequence charsequence = html.fromhtml (Html);         textview.settext (charsequence)         //set * * * Light effect          textview.setsingleline (True);         textview.setellipsize (TextUtils.TruncateAt.MARQUEE);         Textview.setmarqueerepeatlimit ( -1);         //set inner fill          textview.setpadding (5, 5, 5, 5);         //Setting width         textview.setfocusableintouchmode (true) ;       &Nbsp; textview.setfocusable (TRUE);         //settings can be clicked on properties          textview.setmovementmethod (Linkmovementmethod.getinstance ());              }     @Override      public boolean oncreateoptionsmenu (Menu menu)  {         // inflate the menu; this adds items to the  action bar if it is present.         Getmenuinflater (). Inflate (R.menu.main, menu);        return  true;    }}

(2) Activity.xml

<relativelayout xmlns:android= "Http://schemas.android.com/apk/res/android"      xmlns:tools= "Http://schemas.android.com/tools"     android:layout_width= "Match_parent"     android:layout_height= "Match_parent"     android:paddingbottom= "@ Dimen/activity_vertical_margin "    android:paddingleft=" @dimen/activity_horizontal_margin "     android:paddingright= "@dimen/activity_horizontal_margin"      android:paddingtop= "@dimen/activity_vertical_margin"     tools:context= ". Mainactivity " >    <TextView         Android:layout_width= "Fill_parent"         android:layout_height= "Wrap_ Content "        android:id=" @+id/textveiw "         android:focusableintouchmode= "true"         android:padding= "10DP"           >        </TextView>      </RelativeLayout>


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/2A/02/wKioL1OBXzyibBkLAAEyKCP6g_8786.jpg "title=" Z.jpg " alt= "Wkiol1obxzyibbklaaeykcp6g_8786.jpg"/>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.