如何处理文本的不同字体大小?

时间:2018-07-31 06:51:22

标签: android performance font-size

这是我的问题。

当我的用户从android选择字体大小较小时,我的应用程序屏幕中的所有文本大小看起来都很好
设置->显示->文字大小->小 Image containing when my font size is small


当我的用户从android选择字体大小较大时,同一应用程序屏幕看起来很乱
设置->显示->文本大小->大 Image containing when my font size is large


如何使我的应用程序屏幕在所有字体大小下看起来更好



<?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:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
    >

    <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingBottom="10dp"
            android:paddingTop="10dp" >

    <de.hdodenhof.circleimageview.CircleImageView
        android:id="@+id/voicemailcontactpic"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:src="@drawable/unknown_contact"
        android:layout_alignParentStart="true"
        android:layout_alignParentLeft="true"
        />


    <TextView
        android:id="@+id/voicemailcontactname"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@color/transparent"
        android:ellipsize="end"
        android:text="Unknown"
        android:maxLines="1"
        android:textSize="14sp"
        android:fontFamily="calibri"
        android:textColor="@color/grey_font"
        android:layout_toEndOf="@id/voicemailcontactpic"
        android:layout_toRightOf="@id/voicemailcontactpic"
        android:layout_alignTop="@+id/voicemailcontactpic"/>

    <TextView
        android:id="@+id/voicemailcontactnumber"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/voicemailcontactname"
        android:layout_alignStart="@+id/voicemailcontactname"
        android:layout_below="@+id/voicemailcontactname"
        android:layout_alignBottom="@+id/voicemailcontactpic"
        android:background="@color/transparent"
        android:ellipsize="end"
        android:maxLines="1"
        android:text="1234"
        android:fontFamily="calibri"
        android:textColor="@color/grey_font"
        android:textSize="12sp" />



    <TextView
        android:id="@+id/voicemaildownloadsize"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="5dp"
        android:layout_marginEnd="5dp"
        android:layout_toStartOf="@id/voicemaildownload"
        android:layout_toLeftOf="@id/voicemaildownload"
        android:layout_alignTop="@id/voicemailcontactpic"
        android:text="122kb"
        android:textSize="12sp"
        android:fontFamily="calibri"
        android:textColor="@color/grey_font"
        android:textAlignment="viewEnd"
        tools:ignore="RtlCompat"
        />

    <TextView
        android:id="@+id/voicemailrecievedtime"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="5dp"
        android:layout_marginEnd="5dp"
        android:layout_toStartOf="@id/voicemaildownload"
        android:layout_toLeftOf="@id/voicemaildownload"
        android:layout_below="@+id/voicemailcontactname"
        android:layout_alignBottom="@id/voicemailcontactpic"
        android:text="12:01 PM"
        android:textAlignment="viewEnd"
        android:textSize="12sp"
        android:fontFamily="calibri"
        android:textColor="@color/grey_font"
        tools:ignore="RtlCompat"
        />

        <com.nexge.nexgetalkclass5.app.voicemail.CircularProgressBar
            android:id="@+id/voice_mail_file_download_Progress"
            style="@style/Widget.ProgressBar.Holo.CircularProgressBar"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="16dp"
            android:layout_marginStart="10dp"
            android:layout_marginEnd="16dp"
            android:layout_centerVertical="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentEnd="true"
            android:visibility="gone"
            />

    <ImageView
        android:id="@+id/voicemaildownload"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_alignBottom="@+id/voicemailcontactpic"
        android:layout_alignTop="@id/voicemailcontactpic"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="20dp"
        android:layout_marginStart="10dp"
        android:layout_marginEnd="20dp"
        android:clickable="false"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:src="@drawable/voicemail_download"
        />

</RelativeLayout>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/voicemail_player_layout"
                android:paddingBottom="10dp"
                >

<ImageView
    android:id="@+id/voicemail_player_play_btn"
    android:layout_width="40dp"
    android:layout_height="40dp"
    android:layout_marginTop="15dp"
    android:layout_marginLeft="60dp"
    android:layout_marginStart="60dp"
    android:src="@drawable/media_player_play"

    />

    <ImageView
        android:id="@+id/voicemail_player_pause_btn"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_marginTop="15dp"
        android:layout_marginLeft="60dp"
        android:layout_marginStart="60dp"
        android:src="@drawable/media_player_pause"
        android:visibility="invisible"
        />

<SeekBar
    android:id="@+id/voicemail_player_seekbar"
    android:layout_width="match_parent"
    android:layout_toEndOf="@+id/voicemail_player_play_btn"
    android:layout_toRightOf="@+id/voicemail_player_play_btn"
    android:layout_alignTop="@+id/voicemail_player_play_btn"
    android:progressTint="@color/colorPrimary"
    android:thumb="@drawable/seekbar_thumb"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dp"
    android:layout_marginRight="20dp"
    android:layout_marginEnd="20dp"/>
<TextView
    android:id="@+id/voicemail_file_start_time_text_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/voicemail_player_seekbar"
    android:layout_alignStart="@+id/voicemail_player_seekbar"
    android:layout_alignLeft="@+id/voicemail_player_seekbar"
    android:layout_marginLeft="10dp"
    android:layout_marginStart="10dp"

    android:fontFamily="calibri"
    />

<TextView
    android:id="@+id/voicemail_file_end_time_text_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:fontFamily="calibri"
    android:layout_alignEnd="@+id/voicemail_player_seekbar"
    android:layout_alignRight="@+id/voicemail_player_seekbar"
    android:layout_below="@+id/voicemail_player_seekbar"
    android:layout_marginRight="10dp"
    android:layout_marginEnd="10dp"

    />
</RelativeLayout>
</LinearLayout>

1 个答案:

答案 0 :(得分:0)

不使用textsize,将textAppearance用于fontSize