askIT

Android Format TextView

Text size

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="Large" />
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="18sp"
    android:text="Size 18 sp" />
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Medium" />
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:text="Small" />

Text color

First make a resource named colors.xml in your values folder:

<?xml version="1.0" encoding="utf-8"?>
<resources>
 <color name="colorWhite">#FFFFFF</color>
 <color name="colorYellow">#FFFF00</color>
 <color name="colorFuchsia">#FF00FF</color>
 <color name="colorRed">#FF0000</color>
 <color name="colorSilver">#C0C0C0</color>
 <color name="colorGray">#808080</color>
 <color name="colorOlive">#808000</color>
 <color name="colorPurple">#800080</color>
 <color name="colorMaroon">#800000</color>
 <color name="colorAqua">#00FFFF</color>
 <color name="colorLime">#00FF00</color>
 <color name="colorTeal">#008080</color>
 <color name="colorGreen">#008000</color>
 <color name="colorBlue">#0000FF</color>
 <color name="colorNavy">#000080</color>
 <color name="colorBlack">#000000</color>
</resources>

Then use them:

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="@color/colorRed"
    android:text="Red" />

Add comment

avatar_blank_60.png

Comment:

Name:

Email:

Comments

1_180303121314.jpg.png

Administrator

1 Jul 2018

How to get bold text in Android?