How to make a fancy transparent menu, such as the "sharing menu" in the Android gallery?

On my Android 2.2.2 device, the gallery looks very nice. What I would like to do in my own application is to click a button and then show a menu that looks like this: enter image description here

Is it using any standard Android themes / styles? Does anyone know an example code to have such a menu?

Edit: I realized that one could simulate this menu using a dialog. To simplify things, I am not using ListView in this example, but only one TextView entry for the dialog:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/layout_root"
              android:orientation="vertical"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              >
    <TextView android:id="@+id/text"
              android:layout_width="wrap_content"
              android:layout_height="fill_parent"
              android:textColor="#FFF"
              android:padding="10dp"
              />
</LinearLayout>

Displaying a dialog when I click a button:

                Dialog dialog = new Dialog(MyActivity.this);
                dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

                dialog.setContentView(R.layout.custom_dialog);

                TextView text = (TextView) dialog.findViewById(R.id.text);
                text.setText("Test option 1");

                WindowManager.LayoutParams WMLP = dialog.getWindow().getAttributes();
                WMLP.gravity = (Gravity.BOTTOM | Gravity.LEFT);
                WMLP.x = 0;
                WMLP.y = 0;
                dialog.getWindow().setAttributes(WMLP);

                dialog.show();

This creates a dialog box that approaches the menu in the picture. However, I still have two problems:

1) , ?

2) , , . , , . :

WMLP.x = middleButton.getLeft() + (middleButton.getWidth() / 2) - dialog.getWindow().getDecorView().getPaddingLeft() - (WMLP.width / 2);

, WMLP.width -2. , , ​​ "wrap_content" ( -2), . , , ?

: : http://www.londatiga.net/it/how-to-create-quickaction-dialog-in-android/

, , .

+5
3

, PopupWindow , litle .

Nine-Path Drawable, .

PS: , .

+1

3 :

  • ( , , , ). ( ), - ( ). , . , , .

  • - . , , , . (). -, - ( , , ), , , .

  • ! ( , Android ... , )

:

? onCreate, . , . , . . !

: view.getLeft( ), view.getLocationOnScreen - .

0
0
source

All Articles