Create a popup dialog like facebook android app

I want to create a popup dialog like in a facebook app with a pointing marker in the selection area. here is an example of how it should look. http://imageshack.us/photo/my-images/9/facebookandroid.png/

Please help if you know something about this.

Thanks in advance.

enter image description here

+3


source to share


2 answers


Maybe your question will be resolved from this



https://github.com/lorensiuswlt/NewQuickAction

+1


source


There are several strategies that can solve this problem, but each solution must deal with the placement of the triangle / pointer at the top of the dialog box, as it must be positioned to indicate the user's choice.

I think the simplest way to solve this problem is:



  • Get started with a transparent theme. So, apply something like android: theme = "@android: style / Theme.Translucent.NoTitleBar" to the activity in the manifest. If you want a title bar then search for the correct android style.
  • Pass additional information about the activity representing the user-selected navigation item. this will be used by the activity to position the triangle pointer.
  • Refer to this further in the onCreate () property by drawing the triangle / pointer in code. This means that you will want to call setContentView (...) in onCreate () and then get a reference to the ViewGroup (i.e. RelativeLayout, AbsoluteLayout, etc.). After that, you can call ViewGroup # addView (View Child, index int) to add an ImageView that represents the triangle. You probably want to use index = 0.
  • Make sure any views you add programmatically are / are not covered (i.e. hidden) by elements in the XML.
  • Adding a triangle is relatively easy, but positioning can be tricky. First of all, the screenshot you took assumes a fixed width device and this is simply not true for an Android app on the market that should run on 1000 screens. The y-coordinate of the triangle / pointer is not an issue, as the top-level height is probably hardcoded. This is the X coordinate and can get tricky. What if the top-level elements stretch? Let's assume we have a reliable / decent way to get the X-position where the center of the triangle / pointer should be. With that in mind, I would try to use a vertical LinearLayout in my work and use an ImageView with a left edge for the triangle / pointer. This is just a guess and you may have to work around it.to get the correct View elements and positioning strategy for your specific implementation.
+1


source







All Articles