【问题标题】:Default notification text size默认通知文本大小
【发布时间】:2018-10-11 06:26:54
【问题描述】:

默认通知文本大小是多少?我使用我的自定义尺寸(简化):

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <ImageView
        android:id="@+id/icon"
        android:layout_width="55dp"
        android:layout_height="55dp"
        android:layout_alignParentLeft="true"
        android:src="@drawable/icon" />

    <TextView
            android:id="@+id/app_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/app_n"
            android:textSize="16sp"/>

</RelativeLayout>

但是,这种方法 (android:textSize="16sp") 不适用于所有设备,文本在其中一些设备上被剪切。我只需要找到一些可以在我的自定义通知布局中使用的默认dimens-ed 变量。

【问题讨论】:

标签: android notifications dimensions text-size


【解决方案1】:

您可以使用自动调整大小

 <?xml version="1.0" encoding="utf-8"?>
<TextView
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:autoSizeTextType="uniform" />

https://developer.android.com/guide/topics/ui/look-and-feel/autosizing-textview

【讨论】:

    【解决方案2】:

    你可以使用这种风格,进入xml:

    标题

    style="@style/TextAppearance.Compat.Notification.Title"
    

    身体

    style="@style/TextAppearance.Compat.Notification"
    

    【讨论】:

    • 仅适用于移动设备,不适用于平板电脑。
    • 这在 Android S (API 31) 中不起作用。原生通知中的标题看起来不同。
    猜你喜欢
    • 1970-01-01
    • 2010-11-22
    • 2014-06-13
    • 2016-05-02
    • 2021-05-22
    • 2011-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多