我正在制作一个警报对话框,并希望在屏幕的最顶部显示它(它的高度应该从最顶部开始)。我该怎么做?这是代码:
AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
m_rb10Minutes = new RadioButton(this);
m_rb10Minutes.setText("10 minutes");
m_rb20Minutes = new RadioButton(this);
m_rb20Minutes.setText("20 minutes");
m_rb30Minutes = new RadioButton(this);
m_rb30Minutes.setText("30 minutes");
LinearLayout linearLayout = new LinearLayout(this);
linearLayout.setBackgroundColor(getResources().getColor(R.color.black));
linearLayout.setLayoutParams( new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT));
linearLayout.setOrientation(1);
linearLayout.addView(m_rb10Minutes);
linearLayout.addView(m_rb20Minutes);
linearLayout.addView(m_rb30Minutes);
alertTimer = alertDialog.create();
alertTimer.setView(linearLayout);
alertTimer.requestWindowFeature((int) Window.FEATURE_NO_TITLE);
WindowManager.LayoutParams WMLP = alertTimer.getWindow().getAttributes();
WMLP.x = 0; //x position
WMLP.y = 0; //y position
alertTimer.getWindow().setAttributes(WMLP);
alertTimer.show();