从棒棒糖源代码中,我可以看到图片大小为128dp,详见
GitHub上的notification_template_material_big_media.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/status_bar_latest_event_content"
android:layout_width="match_parent"
android:layout_height="128dp"
android:background="#00000000"
android:tag="bigMediaNarrow"
>
<ImageView android:id="@+id/icon"
android:layout_width="128dp"
android:layout_height="128dp"
android:scaleType="centerCrop"
/>
</RelativeLayout>
这是用于具有3个或更少操作按钮的扩展布局。如需了解更多信息,请查看 GrepCode上的Notification.MediaStyle.getBigLayoutResource(int),如果存在更多按钮,则似乎使用 notification_template_material_big_media.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/status_bar_latest_event_content"
android:layout_width="match_parent"
android:layout_height="128dp"
android:background="#00000000"
android:tag="bigMedia"
>
<include layout="@layout/notification_template_icon_group"
android:layout_width="@dimen/notification_large_icon_width"
android:layout_height="@dimen/notification_large_icon_height"
/>
</RelativeLayout>
而notification_template_icon_group.xml则长这样:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:internal="http://schemas.android.com/apk/prv/res/android"
android:layout_width="@dimen/notification_large_icon_width"
android:layout_height="@dimen/notification_large_icon_height"
android:id="@+id/icon_group"
>
<ImageView android:id="@+id/icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="12dp"
android:layout_marginBottom="12dp"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
android:scaleType="centerInside"
/>
<ImageView android:id="@+id/right_icon"
android:layout_width="16dp"
android:layout_height="16dp"
android:padding="3dp"
android:layout_gravity="end|bottom"
android:scaleType="centerInside"
android:visibility="gone"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
/>
</FrameLayout>
您可以在.../res/values/dimens.xml中找到notification_large_icon_width
和notification_large_icon_height
:
<!-- The width of the big icons in notifications. -->
<dimen name="notification_large_icon_width">64dp</dimen>
<!-- The width of the big icons in notifications. -->
<dimen name="notification_large_icon_height">64dp</dimen>
最终答案是 - 如果有3个或更少的操作按钮,则扩展布局为128dp,如果有超过3个,则为64dp。
MediaStyle
的最终图形将显示为锁屏的背景,因此我选择解码到设备的最大尺寸。虽然这可能不是理想的... - initramfs