当前位置:网站首页>Create dialog style windows with popupwindow
Create dialog style windows with popupwindow
2022-07-07 17:37:00 【XLMN】
Use popupwindow Create a dialog style window
public class MainActivity extends Activity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.popupwindow);
// load r.layout.popup The corresponding layout file
View root = this.getLayoutInflater().inflate(R.layout.popup, null);
// Create popupwindow object
final PopupWindow pw = new PopupWindow(root, 1560, 1720);
Button bt = findViewById(R.id.button2);
bt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// The following pull mode shows
pw.showAsDropDown(v);
// take popupwindow Display in the specified location
pw.showAtLocation(findViewById(R.id.button2), Gravity.CENTER, 20, 20);
}
});
// obtain popupwindow Medium close button
root.findViewById(R.id.close).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// close popupwindow
pw.dismiss();
}
});
}
}
<ImageView
android:layout_width="wrap_content"
android:layout_height="560dp"
android:src="@drawable/mia1" />
<Button
android:id="@+id/close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" close " />
<?xml version="1.0" encoding="utf-8"?> <Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=" eject popop window " />

边栏推荐
猜你喜欢
随机推荐
Matplotlib绘制三维图形
99% of users often make mistakes in power Bi cloud reports
PLC: automatically correct the data set noise, wash the data set | ICLR 2021 spotlight
使用 xml资源文件定义菜单
Linux 安装mysql8.X超详细图文教程
Solidity函数学习
User defined view essential knowledge, Android R & D post must ask 30+ advanced interview questions
imageswitcher的功能和用法
The top of slashdata developer tool is up to you!!!
MySQL implements the query of merging two fields into one field
serachview的功能和用法
【黄啊码】为什么我建议您选择go,而不选择php?
在窗口上面显示进度条
企业即时通讯软件是什么?它有哪些优势呢?
Devops' operational and commercial benefits Guide
麒麟信安中标国网新一代调度项目!
Flash build API Service - generate API documents
专精特新软件开发类企业实力指数发布,麒麟信安荣誉登榜
浅谈 Apache Doris FE 处理查询 SQL 源码解析
【分布式理论】(一)分布式事务








