Android widget preview image

一世执手 提交于 2019-12-11 09:23:10

问题


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:

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?


回答1:


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.



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

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