Question

As I have been seeing out there, most of Android Widget preview images follow a design pattern which contains a simple image Centre-Vertical and left aligned with the same image's big grey shadow below it. See the Android Contacts Widget image:

enter image description here

If the user wants to add the widget to the screen dragging it, the logo will be the only image object which is going to be dragged and not its shadow. Trying to emulate this kind of images for my widget, I have created a simple PNG24 with a logo and its shadow below, but when dragging it both the logo and the shadow are dragged, and not just the logo as the mentioned widgets do.

How do they do to achieve that behaviour?

Was it helpful?

Solution

The design pattern you are talking about it's only applied to bookmark widgets, and its done automatically.

This is, when your activity uses the intent filter ACTION_CREATE_SHORTCUT, the launcher app adds a widget to its widget list and uses the android:icon attribute of that activity to create that design. If you don't provide an android:icon attribute in that activity, it will use the application icon

You can easily see the expected result without really implementing the functionality by adding:

<intent-filter>
    <action android:name="android.intent.action.CREATE_SHORTCUT" />
</intent-filter>

to one of your activities.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top