0

I want to Open a Popup View on click of a Button, But the Activity behind the PopUp should be visible as the Background of the Created PopUp needs to be Transparent on demand.

Gautam
  • 7,868
  • 12
  • 64
  • 105
David Brown
  • 4,783
  • 17
  • 50
  • 75

3 Answers3

2

you can do as below

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();

where temp is your transperent layout.

Dhruvil Patel
  • 2,910
  • 2
  • 22
  • 39
  • Thanks xitij, Got it done by simply making the Theme Transparent in the AndroidManifest.xml file. "android:theme="@android:style/Theme.Translucent.NoTitleBar" – David Brown Aug 06 '12 at 07:19
1

My code for popup :-

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();
}});`
grv_9098
  • 465
  • 5
  • 16
0

Take a look at making a Dialog Fragment and this answer

Community
  • 1
  • 1
Gautam
  • 7,868
  • 12
  • 64
  • 105