Customize Quick Action Dialog for Android

I am developing an application in which I have to show a quick action dialog with the click of a button. Here is an example of how I want to implement it.

What I want to implement.

So far, I have not been able to figure out how to create a custom quick action dialog. But I tried to use activity, and some - what is close to me, what should I achieve. Here is what I have done so far.

When I click the button, I pass the intention of the activity:

if (v.getId() == R.id.points) {
        Toast.makeText(MainActivity.this, "Clicked on points",
                Toast.LENGTH_SHORT).show();
        Intent i = new Intent(MainActivity.this, PointsActionMenu.class);
        startActivity(i);
    }

And I used styles.xmlto make the activity transparent.

styles.xml

<style name="Theme.Transparent" parent="android:Theme">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:backgroundDimEnabled">false</item>
</style>

By implementing these things, I have this interface on my screen. Reached till here

Now I have two questions:

  • . , . 2-3 , .
  • , , , .

.

.

+5
2

, . .

What i found

.

WindowManager.LayoutParams wmlp = this.getWindow().getAttributes();

    wmlp.gravity = Gravity.TOP | Gravity.LEFT;
    wmlp.x = 80; // x position
    wmlp.y = 60; // y position
+2

, , . dp :

int x = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 80, getResources().getDisplayMetrics());
int y = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 60, getResources().getDisplayMetrics());

EDIT:

wmlp.x = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 80, getResources().getDisplayMetrics());
wmlp.y = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 60, getResources().getDisplayMetrics());
+2

All Articles