在弹出窗口android中显示活动

时间:2013-04-08 12:37:42

标签: android android-activity popupwindow

我有一项任务是制作一个看起来像facebook通知屏幕的活动 请参阅附图

enter image description here

任何人都可以通过教程或示例帮助我,让我的活动看起来像这样吗?

2 个答案:

答案 0 :(得分:1)

//尝试这个我觉得它可能有帮助你

LayoutInflater inflater = (LayoutInflater) youractivityname.this
                        .getSystemService(LAYOUT_INFLATER_SERVICE);

                View pview;
                pview = inflater.inflate(R.layout.Yourlayoutname, null);

                PopupWindow cp = new PopupWindow(pview, LayoutParams.WRAP_CONTENT,
                        LayoutParams.WRAP_CONTENT, true);
                cp.setBackgroundDrawable(new BitmapDrawable());
                cp.showAtLocation(v, Gravity.CENTER, 0, 0);
                cp.update(0, 0, 500, 350);

答案 1 :(得分:1)

为了达到这个效果,我使用了一个带有对话框主题的普通活动,并将它的背景设置为透明,并覆盖onAttachActivity事件以设置我想要的新活动的位置,宽度和高度

相关问题