【发布时间】:2019-03-01 15:32:12
【问题描述】:
美好的一天。 我为通知创建了完全自定义的视图。但在不同的设备上左(开始)边距不同。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
android:orientation="vertical"
android:layout_marginEnd="@dimen/notificationContentInsert"
android:layout_marginStart="@dimen/notificationContentInsert"
>
其中的 notificationContentInsert 在 values/dimens.xml 中是 16dp
F.e.
在我的 OnePlus 6 (1080 x 2280) 上,边距为 16dp 开始所有通知 (包括系统通知和其他类似 gmail)有相同的开始 边距,看起来不错。
但在三星 Tab A(9.7",1024x768)上,16dp 看起来比另一个小 通知。
我也尝试使用 sdk 属性 android:dimen/notification_content_margin_start 但是这个属性是私有的,我得到编译异常 AAPT:错误:资源 android:dimen/notification_content_margin_start 是私有的。
有没有办法获得设备指定的通知内容填充?谢谢
【问题讨论】:
-
您想出解决这个问题的办法了吗?我也需要做同样的事情。
-
@FurkanYurdakul 很遗憾没有
标签: android notifications android-screen-support