在视图的前景中打开视图作为弹出窗口

时间:2012-08-06 07:08:52

标签: android popup transparent

我想点击一个按钮打开一个弹出视图,但PopUp背后的活动应该是可见的,因为创建的PopUp的背景需要是透明的。

3 个答案:

答案 0 :(得分:2)

你可以这样做

final Dialog nagDialog = new Dialog(MyActivity.this,android.R.style.Theme_Translucent_NoTitleBar);
                nagDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 
                nagDialog.setCancelable(true);
                nagDialog.setContentView(R.layout.temp);


                nagDialog.show();

其中temp是您的transperent布局。

答案 1 :(得分:1)

我的弹出代码: -

LayoutInflater layoutInflater  =     (LayoutInflater)IOStatusActivity.this.getSystemService(LAYOUT_INFLATER_SERVICE)    
final View popupView = layoutInflater.inflate(R.layout.popupai, null);  

final PopupWindow popupWindowDi = new PopupWindow(popupView,  LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);  

final   TextView txtReadVal = (TextView)popupView.findViewById(R.id.lblPopUpAiReadFrmPLC);
final   EditText txtExpVal = (EditText)popupView.findViewById(R.id.txtPopUpAiExpVal);
Button btnDismiss = (Button)popupView.findViewById(R.id.btnPopUpAiCancle);                          
btnDismiss.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v) {
popupWindowDi.dismiss();
}});`

答案 2 :(得分:0)

看看制作Dialog Fragment 这个answer