How to add text hyperlink in Android TextView

0

There are situation in android development when you will like to add a hyperlink in a TextView. A typical example I have experienced in the past is on SignUp page.

In most SignUp pages, there is always a little information that usually read “By signing up you have accepted to abide by our terms, conditions and policy“. This text is always hyperlinked.

The TextView linksClickable property should be set to true.

The autoLink property value can take any of the following – email, phone,  web, map.

The code example is shown below.

<TextView
            android:id="@+id/policy"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/_8sdp"
            android:padding="@dimen/_4sdp"
            android:autoLink="web"
            android:linksClickable="true"
            android:textColorLink="@color/colorBlack"
            android:text="@string/terms_of_service"
            android:textColor="@color/colorWhite"
            android:textSize="@dimen/_10sdp"
            android:textStyle="italic" />

If you have an alternative solution kindly share it with us.
Edited question