Android-textview (Text display component 2)

Source: Internet
Author: User

---restore content starts---

1. Create Android Project

2.TextView Text color settings

<?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"
>
<textview
Android:id= "@+id/mytext1"
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"
android:textcolor= "#ffff00"
android:text= "@string/hello"
/>
</LinearLayout>
Run the following effect

3.TextView Text Size setting

<?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"
>
<textview
Android:id= "@+id/mytext1"
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"
Android:textcolor= "#ffff00"
android:textsize= "22px"
android:text= "@string/hello"
/>
</LinearLayout>

Run the following effect

4.TextView up and down distance settings

<textview
Android:id= "@+id/mytext2"
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"
Android:layout_margin= "30px"
android:text= "url: www.baidu.com"/>

Run the following effect

5.TextView distance from top

<textview
Android:id= "@+id/mytext3"
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"
android:layout_margintop= "10px"

android:maxlength= "3" >(up to 3 words)
android:text= "Abababababababa"/>

Run the following effect

Text display on a 6.TextView background

<textview
Android:id= "@+id/mytext4"
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"
android:background= "@drawable/log" (background image)
Android:textstyle= "Bold" (text bold)
Android:text= "This is the text on the background image"/>

Run the following effect

7.TextView URL Link

<textview
Android:id= "@+id/mytext5"
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"
Android:textcolor= "#000000"
Android:textsize= "36PX"
android:autolink= "All"
android:text= "url: www.baidu.com"/>

Run the following effect

8. Use style sheets to define common component properties for easy maintenance

<?xml version= "1.0" encoding= "Utf-8"?>
<resources>
<style name= "style_msg" >
<item name= "Android:layout_width" >fill_parent</item>
<item name= "Android:layout_height" >wrap_content</item>
<item name= "Android:textcolor" > #000000 </item>
<item name= "android:textsize" >36px</item>
<item name= "Android:autolink" >all</item>
</style>
</resources>
Note: This file is placed in the values directory

Main.xml Use the following

<textview
Android:id= "@+id/mytext5"
style= "@style/style_msg"
android:text= "url: www.baidu.com"/>

Run the following effect

Android-textview (Text display component 2)

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.