Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/202.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android-浮动警报对话框,仍然允许用户在主布局/活动中输入_Android_Android Dialogfragment_Dialogfragment - Fatal编程技术网

Android-浮动警报对话框,仍然允许用户在主布局/活动中输入

Android-浮动警报对话框,仍然允许用户在主布局/活动中输入,android,android-dialogfragment,dialogfragment,Android,Android Dialogfragment,Dialogfragment,你好,为这个令人困惑的标题道歉 我正在创建一个android应用程序,我需要一个对话框/弹出窗口出现在特定的X Y位置。我已经有一个工作对话框Fragmet,如下所示: public class ItemDialog extends DialogFragment implements OnClickListener{ //a lot of public and private variables here public interface onSubmitListener {

你好,为这个令人困惑的标题道歉

我正在创建一个android应用程序,我需要一个对话框/弹出窗口出现在特定的X Y位置。我已经有一个工作对话框Fragmet,如下所示:

public class ItemDialog extends DialogFragment implements OnClickListener{

    //a lot of public and private variables here

    public interface onSubmitListener {
        void setOnSubmitListener(String qty, String disc, String instructions, UOMClass uom);  
    }  

    @Override  
    public Dialog onCreateDialog(Bundle savedInstanceState) {  

        final Dialog dialog = new Dialog(getActivity());  
        dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,  
                WindowManager.LayoutParams.FLAG_FULLSCREEN);  

        LayoutInflater layoutInflater = (LayoutInflater) getActivity()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        View layout2 = layoutInflater.inflate(R.layout.fragment_item_dialog, null);

        dialog.setContentView(layout2);  
        setStyle(DialogFragment.STYLE_NORMAL, R.style.MyDialog);

        //snip snip more code   

        dialog.show();  

        //buttons - I set the buttons here

        //editTexts - I set the edit texts here

        //TextViews - I set the text views here

        return dialog;  
    }  

    //more functions here

}
我从我的基本活动中称之为:

ItemDialog itemDialog = new ItemDialog();

//pass values from base activity to the ItemDialog here

itemDialog.show(getFragmentManager(), "");
但是,我需要能够在其中的编辑文本中看到基本活动和输入值。到目前为止,我的DialogFragment占据了屏幕的很大一部分,我无法看到它背后的活动。在对话框片段外单击也会取消它

我搜索了如何使警报对话框浮动,但没有结果

是否有一种方法可以在屏幕的某个区域显示对话框片段,以允许用户查看并仍然在基本活动中输入值


非常感谢您的帮助。

您可以获取window对象并在下面设置其布局参数,代码可能会对您有所帮助

Window window = getDialog().getWindow();

    // set "origin" to top left corner, so to speak
    window.setGravity(Gravity.TOP|Gravity.LEFT);

    // after that, setting values for x and y works "naturally"
    WindowManager.LayoutParams params = window.getAttributes();
    params.x = 300;
    params.y = 100;
    window.setAttributes(params);
更多信息
您也可以将背景色或位图设置为对话框

谢谢。我还添加了
window.setFlags(WindowManager.LayoutParams.FLAG\u NOT\u TOUCH\u model,WindowManager.LayoutParams.FLAG\u NOT\u TOUCH\u model);window.clearFlags(WindowManager.LayoutParams.FLAG\u DIM\u后方)
因此用户仍然可以与基本活动交互更直观。您可以将对话框设置为特定的x和y坐标。并将设置为可取消(false)。并将CanceledOnTouchOut设置为(false)。我不确定它是否对你有帮助。我没有试过。对不起,两天后碰到了这个。DialogFragment似乎阻止基本活动中的任何编辑文本显示软键盘?这里的评论和文章->对我帮助很大