【问题标题】:Open the View as Popup in the foreground of the View在视图的前台打开视图作为弹出窗口
【发布时间】:2012-08-06 15:22:04
【问题描述】:

我想在单击按钮时打开弹出视图,但弹出窗口后面的 Activity 应该是可见的,因为创建的弹出窗口的背景需要按需透明。

【问题讨论】:

  • 我不知道该怎么办!!! M 正在寻找灵魂。

标签: android popup transparent


【解决方案1】:

你可以这样做

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 是您的透明布局。

【讨论】:

  • 感谢 xitij,只需在 AndroidManifest.xml 文件中使主题透明即可完成。 "android:theme="@android:style/Theme.Translucent.NoTitleBar"
【解决方案2】:

我的弹出窗口代码:-

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

【讨论】:

    【解决方案3】:

    看看制作Dialog Fragment 还有这个answer

    【讨论】:

      猜你喜欢
      • 2011-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-15
      • 2020-09-28
      • 1970-01-01
      相关资源
      最近更新 更多