定制的Andr​​oid迅速采取行动对话迅速、行动、Andr、oid

2023-09-12 05:10:49 作者:姐就不淑女怎么了つ

我正在开发中,我必须展示在点击一个按钮,快速行动对话框的应用程序。下面是一个例子,我希望它实现。

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.

直到现在我无法弄清楚如何使一个自定义的快捷操作对话框。但是,我使用的是活动的人已经尝试了一些什么,我接近我有什么来实现的。这是我做了什么至今。

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);
    }

和我已经使用 styles.xml ,使活动透明。

And I have used styles.xml to make the activity transparent.

Styles.xml

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>

实施这些事我已经得到这个UI我的屏幕上。

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

现在,我有两个问题:

在我使用了活动,并设计了一个布局工作,我的需要。是 有没有简单的方法来实现这一点使用快速行动对话框。一世 已通过2-3例子是走了,但我无法 根据我的需要定制。 据我使用的活性已实施,它被示出在屏幕的中心,我可以改变的默认位置 活动中所示的画面右上角。 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. 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.

无论是回答能帮助我。

任何形式的帮助将是AP preciated这一点。

Any kind of help will be appreciated for this.

推荐答案

我想我解决我的问题。这里现在是什么样子。

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

综合以下code设置它的位置。

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