Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customize quick action dialog for android

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

What I want to implement.

Till now I could not figure out how to make a custom quick action dialog. But I have tried using an activity and some what I'm near what I have to achieve. Here is what I have done till now.

On click of the button I'm passing intent to 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 have used styles.xml to 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>

Implementing these things I have got this UI on my screen. Reached till here

Now, I have two questions:

  1. I have used activity and designed a layout to work for my needs. Is there any easy way to implement this using quick action dialog. I have gone through 2-3 examples for that, but I was unable to customize it according to my need.
  2. As far as I have implemented using an activity, it is showing in the center of the screen, can I change the default place of the activity to right corner as shown in the picture.

Either of the answer can help me.

Any kind of help will be appreciated for this.

like image 953
Anupam Avatar asked Oct 04 '22 08:10

Anupam


1 Answers

I think I solved my problem. Here it is now what it looks like.

What I found

Integrated the following code for setting it's position.

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

    wmlp.gravity = Gravity.TOP | Gravity.LEFT;
    wmlp.x = 80; // x position
    wmlp.y = 60; // y position
like image 158
Anupam Avatar answered Oct 13 '22 10:10

Anupam