Android Textsize in PX, DP, MM, PT, SP and in

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="5"
    android:padding="10dp"

    tools:context="com.example.anshu.demo.pixel">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:paddingTop="10dp"
        android:gravity="center"
        android:layout_gravity="center"
        android:text="This is demo"
        android:textSize="20dp"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:text="This is demo"
        android:gravity="center"
        android:paddingTop="10dp"
        android:textSize="20mm"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:layout_weight="1"
        android:paddingTop="20px">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:paddingLeft="10px"
            android:gravity="center"
            android:textSize="20px"
            android:text="This is demo"
            android:paddingTop="20px"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:paddingLeft="10px"
            android:gravity="center"
            android:textSize="20pt"
            android:text="This is demo"
            android:paddingTop="20px"/>

    </LinearLayout>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:gravity="center"
        android:text="This is demo"
        android:textSize="20sp"
        android:paddingTop="10dp"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:text="This is demo"
        android:gravity="center"
        android:textSize="1in"
        android:paddingTop="10dp"/>

</LinearLayout>

0 comments: