如何让Facebook Messenger的类似通知,像这样的机器人 [英] how to make facebook messenger like notification like this in Android
问题描述
我想执行的通知像在下面的图片。通知出现的任何时间。我认为这是理所当然的后台服务等待新的邮件从服务器,则表明这一点。我认为这是实现这一自定义UI对话的活动。我对么 ?而且它是从服务正常startActivity方法?怎么办的过渡动画,使其慢慢出现从左到右与缩放时显示出来?
I want to implement notification like the one in the following image. Notification appears any time. I think it's of course a background service waiting for new messages from the server then shows this. What I think this is an activity implemented as dialog with this custom UI. Am I correct ? And is it a normal startActivity method from the service ? and how to do the transition animation to make it appears slowly from left to right with zooming when show up ?.
多谢了。
推荐答案
看看这个链接 HTTP://www.piwai。信息/ chatheads-基础/ 。他提供了有关如何添加到您的屏幕上的信息。
Check out this link http://www.piwai.info/chatheads-basics/. He provides information about how to add them on your screen.
关键是要增加一个查看
到窗口管理器
像下面code
The trick is to add a View
to the WindowManager
like following code
private WindowManager windowManager;
private ImageView chatHead;
public void addView()
{
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
chatHead = new ImageView(this);
chatHead.setImageResource(R.drawable.android_head);
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);
params.gravity = Gravity.TOP | Gravity.LEFT;
params.x = 0;
params.y = 100;
windowManager.addView(chatHead, params);
}
不要忘了添加的权限<使用-权限的Android:名称=android.permission.SYSTEM_ALERT_WINDOW/>
这篇关于如何让Facebook Messenger的类似通知,像这样的机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!