最近因为要用到PopupWindow,所以,就在网上搜索了一下,发现挺多关于这样的文章,现在我把它们整理了一下。
1、Android PopupWindow 的使用技巧,http://www.cnblogs.com/sw926/p/3230659.html
2、Android PopupWindow 的使用和分析,http://www.cnblogs.com/mengdd/p/3569127.html
3、Android PopupWindow 实现从底部弹出或滑出选择菜单或窗口,http://104zz.iteye.com/blog/1685389
本文是整理上面三篇文章而成,绝大部分代码是使用第三篇的,如有不妥,请联系。
一、第一步就是创建布局文件
res/layout/finish_project_popupwindow.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:id="@+id/popupwindow_Button_saveProject"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_marginTop="10dip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/popupwindow_Button_saveProject" />
<Button
android:id="@+id/popupwindow_Button_abandonProject"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:lay