to top
TextLinkify / res / layout /

sample_main.xml

1
<!--
2
  Copyright 2013 The Android Open Source Project
3
 
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
  you may not use this file except in compliance with the License.
6
  You may obtain a copy of the License at
7
 
8
        http://www.apache.org/licenses/LICENSE-2.0
9
 
10
  Unless required by applicable law or agreed to in writing, software
11
  distributed under the License is distributed on an "AS IS" BASIS,
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
  See the License for the specific language governing permissions and
14
  limitations under the License.
15
-->
16
 
17
    <ScrollView
18
        xmlns:android="http://schemas.android.com/apk/res/android"
19
        xmlns:tools="http://schemas.android.com/tools"
20
        android:layout_width="wrap_content"
21
        android:layout_height="wrap_content"
22
        tools:context=".MainActivity">
23
 
24
        <LinearLayout
25
            android:orientation="vertical"
26
            android:layout_width="fill_parent"
27
            android:layout_height="fill_parent"
28
            android:paddingBottom="@dimen/activity_vertical_margin"
29
            android:paddingLeft="@dimen/activity_horizontal_margin"
30
            android:paddingRight="@dimen/activity_horizontal_margin"
31
            android:paddingTop="@dimen/activity_vertical_margin">
32
 
33
 
34
            <TextView
35
                android:layout_width="wrap_content"
36
                android:layout_height="wrap_content"
37
                android:text="@string/intro" />
38
 
39
            <!-- text_auto_linkify automatically linkifies things like URLs and phone numbers. -->
40
            <TextView
41
                android:id="@+id/text_auto_linkify"
42
                style="@style/LinkText"
43
                android:layout_width="match_parent"
44
                android:layout_height="wrap_content"
45
                android:autoLink="all"
46
                android:text="@string/link_text_auto" />
47
 
48
            <!--
49
                   text_html_resource uses a string resource containing explicit anchor tags (<a>)
50
                   to specify links.
51
            -->
52
            <TextView
53
                android:id="@+id/text_html_resource"
54
                style="@style/LinkText"
55
                android:layout_width="match_parent"
56
                android:layout_height="wrap_content"/>
57
 
58
            <!-- text_html_program builds the text in the Java code using HTML. -->
59
            <TextView
60
                android:id="@+id/text_html_program"
61
                style="@style/LinkText"
62
                android:layout_width="match_parent"
63
                android:layout_height="wrap_content" />
64
 
65
            <!-- text_spannable builds the text in the Java code without using HTML. -->
66
            <TextView
67
                android:id="@+id/text_spannable"
68
                style="@style/LinkText"
69
                android:layout_width="match_parent"
70
                android:layout_height="wrap_content" />
71
        </LinearLayout>
72
    </ScrollView>