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