简体   繁体   English

将活动对齐在左上角的对话框中

[英]Align an activity as dialog on top left

i know this question was asked for aligning a dialog on the left, but here i'm using an activity with a 我知道这个问题被要求在左边对齐一个对话框,但在这里我正在使用一个带有一个的活动

android:theme="@android:style/Theme.Dialog" and the problem is that it's display at the center of the screen and i want to display on the top left corner. android:theme="@android:style/Theme.Dialog" ,问题是它显示在屏幕中央,我想显示在左上角。

is there any way to do so ? 有没有办法这样做?

i have tried using the android:layout_gravity="top|left" on my concerned activity .xml but that doesn't work. 我已经尝试在我关注的活动.xml上使用android:layout_gravity="top|left"但这不起作用。

Thank you for your help 谢谢您的帮助

Try this on your onCreate of dialog activity 在onCreate对话框活动中尝试此操作

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

        wmlp.gravity = Gravity.TOP | Gravity.LEFT;

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM