当前位置:网站首页>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 " />
边栏推荐
- 本周小贴士131:特殊成员函数和`= default`
- 麒麟信安中标国网新一代调度项目!
- 【信息安全法律法規】複習篇
- mysql官网下载:Linux的mysql8.x版本(图文详解)
- From Devops to mlops: how do it tools evolve to AI tools?
- 【分布式理论】(二)分布式存储
- Leetcode brush questions day49
- Problems encountered in Jenkins' release of H5 developed by uniapp
- 自定义View必备知识,Android研发岗必问30+道高级面试题
- Audio Device Strategy 音频设备输出、输入 选择 基于7.0 代码
猜你喜欢
随机推荐
如何在软件研发阶段落地安全实践
本周小贴士#136:无序容器
mysql官网下载:Linux的mysql8.x版本(图文详解)
L1-023 输出GPLT(Lua)
Leetcode brush questions day49
国内首创!Todesk将RTC技术融入远程桌面,画质更清晰操作更流畅
Biped robot controlled by Arduino
【网络攻防原理与技术】第3章:网络侦察技术
无法链接远程redis服务器(解决办法百分百)
第3章业务功能开发(用户访问项目)
What is cloud computing?
99%的人都不知道|私有化部署还永久免费的即时通讯软件!
Matplotlib绘图界面设置
使用 xml资源文件定义菜单
Audio device strategy audio device output and input selection is based on 7.0 code
专精特新软件开发类企业实力指数发布,麒麟信安荣誉登榜
【源码解读】| LiveListenerBus源码解读
alertDialog創建对话框
Solid function learning
本周小贴士#134:make_unique与私有构造函数