Create styling string from resources - Apk Apps For you

Apk Apps For you

Foxi apk download latest version for Android,fifa 20 download for Android,fifa 20 download,mobile games,games download,Android games free download apk

Click here to download

Search This Blog

2 > 3 4

Wednesday, July 20, 2016

Create styling string from resources

This example show how to create partial styling string from resources:


Edit values/strings.xml to add string resources with styling:
<resources>
<string name="app_name">AndroidStylingStringResources</string>
<string name="normal_name">It is Normal String</string>
<string name="italic_name">Partial <i>Italic String</i> from resources</string>
<string name="bold_name">Partial <b>Bold String</b> from resources</string>
<string name="underline_name">Partial <u>Underline String</u> from resources</string>
</resources>


Edit layout/activity_main.xml to use the string resources:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:orientation="vertical"
tools:context="com.blogspot.android_er.androidstylingstringresources.MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:layout_gravity="center_horizontal"
android:autoLink="web"
android:text="http://android-er.blogspot.com/"
android:textStyle="bold"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="28dp"
android:text="@string/normal_name"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="28dp"
android:textStyle="italic"
android:text="Whole TextView in italic style"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="28dp"
android:text="@string/italic_name"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="28dp"
android:text="@string/bold_name"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="28dp"
android:text="@string/underline_name"/>

</LinearLayout>



No comments:

Post a Comment

Featured Post

Stumble Guys MOD APK 0.54.2

Popular Posts

Advertisement

2 > 3 4