Does the text size not change for different screen layouts?

I'm trying to make my screen with multiple screens supported, because I created a different layout folders, such as layout-large, layout-small, layout-xlarge, layout-sw320dp, layout-sw480dp, I set the size of the text in the sp in each folder, and I mentioned the different sizes of text for each layout folder, but the text does not is changing.

Here is my xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/gray_pager"
    android:orientation="vertical"
    >

    <LinearLayout
        android:id="@+id/firstscreen_call_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="5dp"
        android:layout_weight="1"
        android:background="@drawable/firstscreen_layout_bg"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="0.55"
            android:background="@color/call_list_1"
           >

            <TextView
                android:id="@+id/call_list_title"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_weight="1"
                android:paddingLeft="10dp"
                android:text="Call List"
                android:textSize="32sp" />

            <ImageView
                android:layout_width="48dp"
                android:layout_height="48dp"
                android:layout_gravity="center"
                android:adjustViewBounds="true"
                android:padding="5dp"
                android:scaleType="fitXY"
                android:src="@drawable/cm_phone_icon"
                 />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="0.45"
            android:background="@color/call_list_2"
            android:orientation="horizontal"
            android:paddingBottom="5dp"

            android:paddingTop="5dp">

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="vertical"
                >

                <TextView
                    android:id="@+id/call_list_client_1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="15sp"
                    android:text="350" />

                <TextView
                    android:id="@+id/call_list_client_2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:maxLines="2"
                    android:textSize="15sp"
                    android:text="Clients 99 Priority" />
            </LinearLayout>

            <View
                android:layout_width="1dp"
                android:layout_height="wrap_content"
                android:background="@color/gray_bg" />

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/call_list_service_1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="15sp"
                    android:text="3250" />

                <TextView
                    android:id="@+id/call_list_service_2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="15sp"
                    android:maxLines="2"
                    android:text="Servicing Contacts" />
            </LinearLayout>

            <View
                android:layout_width="1dp"
                android:layout_height="wrap_content"
                android:background="#e1e1e1" />

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/call_list_assigned_1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="15sp"
                    android:text="250" />

                <TextView
                    android:id="@+id/call_list_assigned_2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:maxLines="2"
                    android:textSize="15sp"
                    android:text="Assigned Contacts" />
            </LinearLayout>

            <View
                android:layout_width="1dp"
                android:layout_height="wrap_content"
                android:background="#e1e1e1" />

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/call_list_custom_1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="15sp"
                    android:text="6" />

                <TextView
                    android:id="@+id/call_list_custom_2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:maxLines="2"
                    android:textSize="15sp"
                    android:text="Custom List" />
            </LinearLayout>

        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/firstscreen_client_note"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="5dp"
        android:layout_weight="1"
        android:background="@drawable/firstscreen_layout_bg"
        android:orientation="vertical">


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="0.55"
            android:background="@color/client_note_1">

            <TextView
                android:id="@+id/client_note_title"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_weight="1"
                android:paddingLeft="10dp"
                android:text="Client Note"
                android:textSize="32sp"
                android:textStyle="normal" />

            <ImageView
                android:layout_width="48dp"
                android:layout_height="48dp"
                android:layout_gravity="center"
                android:adjustViewBounds="true"
                android:padding="5dp"
                android:scaleType="fitXY"
                android:src="@drawable/cm_note_icon" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="0.45"
            android:background="@color/client_note_2"
            android:orientation="horizontal"
            android:paddingBottom="5dp"
            android:paddingTop="5dp">

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="vertical"
                >

                <TextView
                    android:id="@+id/client_note_notes_1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="15sp"
                    android:text="10" />

                <TextView
                    android:id="@+id/client_note_notes_2"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="15sp"
                    android:maxLines="2"
                    android:text="Notes Logged Today" />
            </LinearLayout>

            <View
                android:layout_width="1dp"
                android:layout_height="wrap_content"
                android:background="#e1e1e1" />

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/client_note_meeting_1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="15sp"
                    android:gravity="center"
                    android:text="7" />

                <TextView
                    android:id="@+id/client_note_meeting_2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="15sp"
                    android:maxLines="2"
                    android:text="Meetings Schedule" />
            </LinearLayout>

            <View
                android:layout_width="1dp"
                android:layout_height="wrap_content"
                android:background="#e1e1e1" />

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/client_note_phone_1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="15sp"
                    android:text="6" />

                <TextView
                    android:id="@+id/client_note_phone_2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:maxLines="2"
                    android:textSize="15sp"
                    android:text="Phone Calls" />
            </LinearLayout>

            <View
                android:layout_width="1dp"
                android:layout_height="wrap_content"
                android:background="#e1e1e1" />

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/client_note_email_1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="15sp"
                    android:text="4" />

                <TextView
                    android:id="@+id/client_note_email_2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:maxLines="2"
                    android:textSize="15sp"
                    android:text="Email(s) Sent" />
            </LinearLayout>

        </LinearLayout>


    </LinearLayout>

    <LinearLayout
        android:id="@+id/firstscreen_to_do_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="5dp"
        android:layout_weight="1"
        android:background="@drawable/firstscreen_layout_bg"
        android:orientation="vertical">


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="0.55"
            android:background="@color/to_do_list_1">

            <TextView
                android:id="@+id/todolist_title"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_weight="1"
                android:paddingLeft="10dp"
                android:text="To-Do List"
                android:textSize="32sp" />

            <ImageView
                android:layout_width="48dp"
                android:layout_height="48dp"
                android:layout_gravity="center"
                android:adjustViewBounds="true"
                android:padding="5dp"
                android:src="@drawable/cm_todo_icon" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="0.45"
            android:background="@color/to_do_list_2"
            android:orientation="horizontal"
            android:paddingBottom="5dp"
            android:paddingTop="5dp">

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/todolist_open_1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="15sp"
                    android:text="20" />

                <TextView
                    android:id="@+id/todolist_open_2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:maxLines="2"
                    android:textSize="15sp"
                    android:text="Open Task" />
            </LinearLayout>

            <View
                android:layout_width="1dp"
                android:layout_height="wrap_content"
                android:background="#e1e1e1" />

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/todolist_expire_1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="15sp"
                    android:text="5" />

                <TextView
                    android:id="@+id/todolist_expire_2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:maxLines="2"
                    android:textSize="15sp"
                    android:text="Expiring Today" />
            </LinearLayout>

            <View
                android:layout_width="1dp"
                android:layout_height="wrap_content"
                android:background="#e1e1e1" />

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/todolist_direct_1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="15sp"
                    android:text="25" />

                <TextView
                    android:id="@+id/todolist_direct_2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:maxLines="2"
                    android:textSize="15sp"
                    android:text="Directed Calls" />
            </LinearLayout>

            <View
                android:layout_width="1dp"
                android:layout_height="wrap_content"
                android:background="@color/gray_bg" />

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/todolist_action_1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="15sp"
                    android:gravity="center"
                    android:text="2" />

                <TextView
                    android:id="@+id/todolist_action_2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="15sp"
                    android:gravity="center"
                    android:maxLines="2"
                    android:text="Actions Pending" />
            </LinearLayout>

        </LinearLayout>

    </LinearLayout>

    <LinearLayout
        android:id="@+id/firstscreen_road_show"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="5dp"
        android:layout_weight="1"
        android:background="@drawable/firstscreen_layout_bg"
        android:orientation="vertical">


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="0.55"
            android:background="@color/roadshow_1">

            <TextView
                android:id="@+id/roadshow_title"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_weight="1"
                android:paddingLeft="10dp"
                android:text="Roadshow"
                android:textSize="32sp" />

            <ImageView
                android:layout_width="48dp"
                android:layout_height="48dp"
                android:layout_gravity="center"
                android:adjustViewBounds="true"
                android:padding="5dp"
                android:scaleType="fitXY"
                android:src="@drawable/cm_roadshow_icon" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="0.45"
            android:background="@color/roadshow_2"
            android:orientation="horizontal"
            android:paddingBottom="5dp"
            android:paddingTop="5dp">

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/roadshow_meeting_1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="15sp"
                    android:text="10" />

                <TextView
                    android:id="@+id/roadshow_meeting_2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="15sp"
                    android:text="Meetings Schedule" />
            </LinearLayout>

            <View
                android:layout_width="1dp"
                android:layout_height="wrap_content"
                android:background="#e1e1e1" />

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/roadshow_ongoing_1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="15sp"
                    android:text="5" />

                <TextView
                    android:id="@+id/roadshow_ongoing_2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="15sp"
                    android:gravity="center"
                    android:text="Ongoing Roadshow" />
            </LinearLayout>

            <View
                android:layout_width="1dp"
                android:layout_height="wrap_content"
                android:background="#e1e1e1" />

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/roadshow_future_1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="15sp"
                    android:text="1" />

                <TextView
                    android:id="@+id/roadshow_future_2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="15sp"
                    android:text="Future Roadshow" />
            </LinearLayout>

            <View
                android:layout_width="1dp"
                android:layout_height="wrap_content"
                android:background="#e1e1e1" />

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/roadshow_mtoday_1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="15sp"
                    android:text="2" />

                <TextView
                    android:id="@+id/roadshow_mtoday_2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="15sp"
                    android:text="Meetings Today" />
            </LinearLayout>

        </LinearLayout>

    </LinearLayout>
</LinearLayout>
+4
source share
2 answers

For best practice for text size, we just need to determine the text size sp.

and we need to set the text below

textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources(). getDimensionPixelSize (R.dimen.textSize));

0

, . .

, res, -

-MDPI

xhdpi

xxhdpi

-w320dp-h408dp

-w480dp-h800dp

-w480dp-h854dp

-w720dp-h1280dp

-w1080dp-h1920dp

, , layout-w1440dp-h2560dp.

""

-1

Source: https://habr.com/ru/post/1620677/


All Articles