Different colors, fonts, linked text TextView

Source: Internet
Author: User

Androidmanifest.xml

<?xml version= "1.0" encoding= "Utf-8"?>
<manifest xmlns:android= "Http://schemas.android.com/apk/res/android"
Package= "Org.crazyit.ui"
Android:versioncode= "1"
Android:versionname= "1.0" >

<uses-sdk
Android:minsdkversion= "10"
Android:targetsdkversion= "/>"

<application
android:icon= "@drawable/ic_launcher"
Android:label= "@string/app_name" >
<activity
Android:name= ". Textviewtest "
Android:label= "@string/app_name" >
<intent-filter>
<action android:name= "Android.intent.action.MAIN"/>

<category android:name= "Android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>

</manifest>

Strings.xml

<?xml version= "1.0" encoding= "Utf-8"?>
<resources>
<string name= "Hello" >hello World, textviewtest!</string>
<string name= "App_name" > different colors, fonts, linked text </string>
</resources>

Main.xml

<?xml version= "1.0" encoding= "Utf-8"?>
<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"
android:orientation= "Vertical"
Android:layout_width= "Fill_parent"
android:layout_height= "Fill_parent"
>
<!--set the font to 20PT, draw a picture at the end of the text box--
<textview
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"
Android:text= "I love Java"
Android:textsize= "20pt"
android:drawableend= "@drawable/ic_launcher"
/>
<!--set middle omitted, all letters capitalized--
<textview
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"
Android:singleline= "true"
Android:text= "I love java I love java I love java I love java I love java i Aaajava"
Android:ellipsize= "Middle"
Android:textallcaps= "true"
/>
<!--add a link to a message, a phone
<textview
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"
Android:singleline= "true"
android:text= "email is [email protected], the phone is 02088888888"
android:autolink= "Email|phone"
/>
<!--set text color, size, and use shadow--
<textview
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"
android:text= "Test Text"
Android:shadowcolor= "#0000ff"
android:shadowdx= "10.0"
Android:shadowdy= "8.0"
android:shadowradius= "3.0"
Android:textcolor= "#f00"
Android:textsize= "18pt"
/>
<!--test Password box--
<textview android:id= "@+id/passwd"
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"
android:text= "@string/hello"
Android:password= "true"
/>
<!--test Checkedtextview
Set the check icon for the text box by checkmark
-
<checkedtextview
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"
android:text= "Selectable text"
android:checkmark= "@drawable/ok"
/>
</LinearLayout>

Java

public class Textviewtest extends Activity
{
Callback this method when the activity is first created
@Override
public void OnCreate (Bundle savedinstancestate)
{
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.main);
}
}

Different colors, fonts, linked text TextView

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.