private void showPopupWindow(View view) {
// 一个自定义的布局,作为显示的内容
View contentView = LayoutInflater
.from(ValidationRunmanActivtiy
.this)
.inflate(R
.layout.pop_xieyi_read, null)
// 设置按钮的点击事件
TextView button = (TextView) contentView
.findViewById(R
.id.bt_read)
WebView webView = (WebView) contentView
.findViewById(R
.id.wb_content)
webView
.setWebViewClient (new MyWebViewClient ())
String url = ServerConfig
.getServer ()
.API_HOST + getResources ()
.getString (R
.string.agreementHtmlUrl)
webView
.loadUrl (url)
final PopupWindow popupWindow = new PopupWindow(contentView,CommonUtils
.dip2px(appContext,
320), CommonUtils
.dip2px(appContext,
520), true)
button
.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(null != popupWindow && popupWindow
.isShowing()) {
popupWindow
.dismiss()
}
}
})
popupWindow
.setTouchable(true)
// 点击外围会隐藏
popupWindow
.setOutsideTouchable(false)
// 如果不设置PopupWindow的背景,无论是点击外部区域还是Back键都无法dismiss弹框 popupWindow
.setBackgroundDrawable(getResources()
.getDrawable(R
.drawable.list_item_cover_center))
// 设置好参数之后再show
popupWindow
.showAtLocation(ll_llll, Gravity
.CENTER ,
0 ,
0 )
}
转载请注明原文地址: https://ju.6miu.com/read-963642.html