View widget

My preview application looks like this: enter image description here

How can I make it look like viewing a WhatsApp chat, small with shadow. Also, other applications on my phone use the same type of preview.

My xml widget:

<?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:

In fact, I noticed all the shortcuts, not widgets, they all look like this.

+4
source share
2 answers

You set the launcher icon as a preview image of the widget.

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

I suggest you take a screenshot of your widget with an emulator that has an application (Preview Widget) for creating a preview with the right size.

Then you can also edit the image if you are not satisfied.

, drawable-nodpi.

: https://developer.android.com/guide/topics/appwidgets/index.html#preview . : Android Widget: previewImage size

+4

, ic_launcher previewImage

  • , Alpha , .

, Photoshop .

.

0

Source: https://habr.com/ru/post/1694183/


All Articles