0

I want to implement a pop up that should appear sliding in on top of the activity and on top of any dialogs that may be on top of that activity. Also, while the pop-up is on screen, the activity and the dialogs in the background should still be interactive (i.e they should react to touches and all the buttons etc. should still be working). After x amount of time, the pop-up should slide out of the screen.

I came up with the following ideas but all of them have a shortcoming of some sort:

1.Custom Toast While the toast would always appear on top of activities and dialogs, I dont think it can be made to slide in and slide out.

2. Custom dialog The dialog would also come on top of activity and dialogs but the problem here is that the while my custom dialog is on screen, the activity and all the previously opened dialogs would not be interactive anymore (i.e. they will not take touches).

3. ImageView in Activity The problem with this approach is obvious: it would always appear behind dialogs.

Any help would be highly appreciated. Thanks !

2 Answers2

1

Here are your options:

1) Go with the Toast and sacrifice your animation in/out

2) Go with the dialog and sacrifice the touch events

3) This isn't viable

I can't even think of how you would do this with a custom view, its just too complex and not something recommended in the Google UX designs.

Maybe for some inspiration of another solution to your problem try here: http://developer.android.com/design/index.html

The real questions to ask are, why do you want this tooltip? What are you trying to achieve? With these answers you can look for a more *Android-esq' solution

Blundell
  • 75,855
  • 30
  • 208
  • 233
  • Thanks for the reply. To answer your question "why do you want this tooltip?" Well, its for a game where the activity has a SurfaceView to hold all the graphics and the menus are implemented as custom Dialogs. The tooltip would serve as Notifications and the animation and touch event constraints are just part of client's requirements :) – Syed Fahad Sultan May 24 '12 at 16:24
  • Sorry for the confusion. But I just realized that pop-up is a far better word as compared to tooltip for what I want to make. I edited the question statement. – Syed Fahad Sultan May 24 '12 at 16:35
0

You really need a View subclass, not a Dialog. Use addView() to add your view, removeView() to remove it.

Via the layout/styling you can make it look like a dialog.

You can use view animation to achieve the slide in/out effects.

Animation slideIn = new TranslateAnimation (windowWidth, 0, 0, 0);
slideIn.setDuration (400);
slideIn.setInterpolator(new LinearInterpolator());
dialogView.startAnimation(slideIn);

Animation slideOut = new TranslateAnimation (0, windowWidth, 0, 0);
slideOut.setDuration (400);
slideOut.setInterpolator(new LinearInterpolator());
dialogView.startAnimation(slideOut);

and use an AnimationListener() onAnimationEnd() to remove the view after sliding out.

You'll need to tweak the x/y parameters of the TranslateAnimation to achieve the effect you want, assume you'll want the dialog centered on x and y axis...

CSmith
  • 13,318
  • 3
  • 39
  • 42
  • But views are always behind Dialogs ! Any View subclass I make, will end up hiding behind the Dialogs that are already open. I have mentioned this in the question statement. – Syed Fahad Sultan May 24 '12 at 16:46