简体   繁体   English

Android小部件预览图

[英]Android widget preview image

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. 正如我一直在那里看到的那样,大多数Android Widget预览图像都遵循一种设计模式,该模式包含一个简单的图像“ Central-Vertical”,并与同一图像下方的大灰色阴影对齐。 See the Android Contacts Widget image: 请参阅Android Contacts窗口小部件图像:

在此处输入图片说明

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. 为了为我的小部件模拟这种图像,我创建了一个简单的PNG24,其下方带有徽标和阴影,但是拖动它时,徽标和阴影都被拖动,而不仅仅是上述小部件的徽标。

How do they do to achieve that behaviour? 他们如何做到这一点?

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. 也就是说,当您的活动使用意图过滤器ACTION_CREATE_SHORTCUT ,启动器应用程序会将小部件添加到其小部件列表中,并使用该活动的android:icon属性来创建该设计。 If you don't provide an android:icon attribute in that activity, it will use the application icon 如果您未在该活动中提供android: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. 您的一项活动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM