当前位置:网站首页>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 " />
边栏推荐
猜你喜欢
企业即时通讯软件是什么?它有哪些优势呢?
Leetcode brush questions day49
命令模式 - Unity
【网络攻防原理与技术】第1章:绪论
viewflipper的功能和用法
LeetCode刷题day49
How to choose the appropriate automated testing tools?
Mrs offline data analysis: process OBS data through Flink job
《世界粮食安全和营养状况》报告发布:2021年全球饥饿人口增至8.28亿
Dateticket and timeticket, functions and usage of date and time selectors
随机推荐
SlashData开发者工具榜首等你而定!!!
Share the latest high-frequency Android interview questions, and take you to explore the Android event distribution mechanism
麒麟信安云平台全新升级!
Mrs offline data analysis: process OBS data through Flink job
Examen des lois et règlements sur la sécurité de l'information
【解惑】App处于前台,Activity就不会被回收了?
本周小贴士#135:测试约定而不是实现
MySQL usage notes 1
Numberpick的功能和用法
字符串 - string(Lua)
Several best practices for managing VDI
状态模式 - Unity(有限状态机)
【TPM2.0原理及应用指南】 1-3章
The mail server is listed in the blacklist. How to unblock it quickly?
Notes on installing MySQL in centos7
Sator launched Web3 game "satorspace" and launched hoobi
MySQL implements the query of merging two fields into one field
Function and usage of textswitch text switcher
【分布式理论】(二)分布式存储
【可信计算】第十三次课:TPM扩展授权与密钥管理