Widget preview image

谁都会走 提交于 2019-12-22 06:59:18

问题


My app preview image looks like this:

How can I make it look like the WhatsApp Chat preview, small with shadow. Also other apps in my phone use the same type of preview.

My widget xml:

<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:initialLayout="@layout/appwidget"
    android:minHeight="40dp"
    android:minWidth="320dp"
    android:previewImage="@mipmap/ic_launcher"
    android:updatePeriodMillis="300000" >
</appwidget-provider>

Manifest:

<receiver
            android:name=".activities.MyWidgetProvider"
            android:label="Example Widget">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>
            <meta-data
                android:name="android.appwidget.provider"
                android:resource="@xml/widget_info" />
        </receiver>

UPDATE:

Actually I have noticed this all shortcuts and not widgets, they all have this look.


回答1:


You have set your launcher icon as widget preview image.

<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
  ...
  android:previewImage="@drawable/widget_preview">
</appwidget-provider>

I suggest you to make a screenshot of your widget with the emulator, which has an application (Widget Preview) for creating a preview with just the right size.

Then, you can also edit the picture if you are not satisfied.

Anyway, be sure to put it on drawable-nodpi.

Official guide to follow: https://developer.android.com/guide/topics/appwidgets/index.html#preview For other dev experience, see this link: Android Widget: previewImage size




回答2:


It seems that you have placed ic_launcher as widget previewImage

  • You have to make a custom image, which have large image as Alpha in background, and on it place your icon in small size on top-right corner.

I have done same thing by generating custom image for previewImage with help of photoshop and its working.

Thank you.



来源:https://stackoverflow.com/questions/49011114/widget-preview-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!