如何在android activity的右上角显示对话框。
下面是我的对话框代码
项目.xml
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="150dp"
android:layout_height="wrap_content" >
<com.CustomToggleButton
android:id="@+id/toggleButton2"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:textOff="@string/off_txt"
android:textOn="@string/on_txt" />
</TableLayout>
ActivityMy.java
dialog_box = new Dialog(ActivityMy.this);
dialog_box.setContentView(R.layout.item);
dialog_box.show();
最佳答案
这样做-
Window window = dialog.getWindow();
WindowManager.LayoutParams wlp = window.getAttributes();
wlp.gravity = Gravity.TOP | Gravity.RIGHT;
wlp.width = LayoutParams.MATCH_PARENT;
wlp.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND;
window.setAttributes(wlp);
关于android - 在android Activity 的右上角显示对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22217059/