我想表明我的android警报就像在桌面
我应该如何接近。
解决方案使它呈现这样
推荐答案
对话框不能没有一个活动被触发。
Dialogs cannot be triggered without an activity..
所以,你可以创建对话框主题的活动。
So ,you can create an activity with dialog theme.
<activity android:theme="@android:style/Theme.Dialog" />
从服务..just称这种活动时,您的通知到达......它会弹出一个类似对话框现在...
Now from your service ..just call this activity when your notification arrives... And it will pop up like a dialog...
编辑:
在呼唤你的活动:
startActivity(intent);
overridePendingTransition(R.anim.enter_anim, R.anim.right_exit_anim);
现在称为动画在资源DIR一个单独的文件夹中创建两个动画文件。
Now create the two anim files in a seperate folder called anim in the resource dir.
enter_anim:
enter_anim:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator">
<translate
android:fromYDelta="20%p" //this takes val from 0(screenbottom) to 100(screentop).
android:toYDelta="0%p" //this takes val from 0(screenbottom) to 100(screentop).
android:duration="700" //transition timing
/>
</set>
exit_anim:
exit_anim:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator">
<translate
android:fromYDelta="0%p" //this takes val from 0(screenbottom) to 100(screentop).
android:toYDelta="20%p" //this takes val from 0(screenbottom) to 100(screentop).
android:duration="700" //transition timing
/>
</set>
编辑2:
创建活动..设计it..then去你的清单文件。而你的活动标记下..添加:
Create an activity.. design it..then go to your manifest file.. And under your activity tag.. add:
<activity android:theme="@android:style/Theme.Dialog" />
现在你的活动会看起来像一个对话框...
Now your activity will look like a dialog...
编辑3:
现在的onCreate()后添加以下功能在您的活动(对话)
Now add the following function in your activity(dialog) after onCreate():
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
View view = getWindow().getDecorView();
WindowManager.LayoutParams lp = (WindowManager.LayoutParams) view.getLayoutParams();
lp.gravity = Gravity.RIGHT | Gravity.BOTTOM;//setting the gravity just like any view
lp.x = 10;
lp.y = 10;
lp.width = 200;
lp.height = 100;
getWindowManager().updateViewLayout(view, lp);
}
我们正在覆盖附加窗口指定屏幕上的活动位置。
We are overriding the attach window to specify the activity location on the screen.
现在您的活动将被放置在屏幕的右侧底部。
Now your activity will be placed in the right side bottom of the screen.
编辑4:
现在给你指定的合作协调分的对话框中,使用lp.x和lp.y ...
Now to give your specified co ordinate points for the dialog, use the lp.x and lp.y...
相关推荐
最新文章