本文实例讲述了Android开发之PopupWindow创建弹窗,对话框的方法。分享给大家供大家参考,具体如下:
PopupWindow可创建类似对话框风格的窗口
使用PopupWindow创建对话框风格的串口秩序如下两步即可:
1。PopupWindow的构造器创建PopupWindow对象
2。PopupWindow的<代码> showAsDropDown() 代码>将其显示效果设置为下拉显示
3。PopupWindow的<代码> showAtLoacation() 代码>方法将<代码> PopupWindow() 代码>在指定位置显示出来
<强>下拉显示效果:强>
公开课MainActivity延伸活动{ 私人PopupWindow PopupWindow; 私人视图根; @Override 保护空白> & lt; & # 63; xml version=" 1.0 " encoding=" utf - 8 " & # 63;比; & lt; LinearLayout xmlns: android=" http://schemas.android.com/apk/res/android " android: id=癅 + id/idtatabHost” android: layout_width=" match_parent " android: layout_height=" match_parent " android: layout_weight=?”比; & lt;按钮 android: id=癅 + id/发送” android: onClick="发送" android:文本="点我一下有惊喜(吓)……” android: layout_width=" match_parent " android: layout_height=" wrap_content "/比; & lt;/LinearLayout> >之前/布局/cell.xml
& lt; & # 63; xml version=" 1.0 " encoding=" utf - 8 " & # 63;比; LinearLayout & lt; android: id=癅 + id/细胞” xmlns: android=" http://schemas.android.com/apk/res/android " android: layout_width=" wrap_content " android: layout_height=" wrap_content " 面向android:=按怪薄北? & lt; ImageView android: layout_width=" match_parent " android: layout_height=" 0 dp” android: layout_weight=" 9 " android: src=" https://www.yisu.com/zixun/@drawable/微信” android: scaleType=" fitXY "/比; & lt;按钮 android: id=癅 + id/button01” android: layout_width=" match_parent " android: layout_height=" 0 dp” android: layout_weight=" 1 " android:背景=" # ffffffff” android:文本=肮乇铡? android: textSize=?5 dp/比; & lt;/LinearLayout> >之前更多关于Android相关内容感兴趣的读者可查看本站专题:《Android开发入门与进阶教程》、《Android调试技巧与常见问题解决方法汇总》、《Android基本组件用法总结》,《Android视图视图技巧总结》,《Android布局布局技巧总结》及《安卓控件用法总结》
希望本文所述对大家Android程序设计有所帮助。
Android开发之PopupWindow创建弹窗,对话框的方法详解