Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Widget preview image

My app preview image looks like this: enter image description here

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.

like image 530
Dim Avatar asked Feb 27 '18 14:02

Dim


1 Answers

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

like image 198
JJ86 Avatar answered Sep 17 '22 08:09

JJ86