初学Android,引用了这篇文章的代码 http://www.cnblogs.com/jiezzy/archive/2012/08/15/2640584.html

使用PopupWindow制作自定义的菜单

先是Layout文件

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 3     android:layout_width="match_parent"
 4     android:layout_height="match_parent"
 5     android:orientation="vertical" >
 6 
 7     <LinearLayout
 8         android:layout_width="match_parent"
 9         android:layout_height="wrap_content"
10         android:gravity="center_horizontal"
11         android:orientation="horizontal" >
12 
13         <Button
14             android:id="@+id/menu_btnBackUp"
15             android:layout_width="wrap_content"
16             android:layout_height="wrap_content"
17             android:layout_marginTop="5dp"
18             android:background="@drawable/backup"
19             android:layout_margin="0.5dp"
20             android:width="100dp" />
21 
22         <Button
23             android:id="@+id/menu_btnRevert"
24             android:layout_width="wrap_content"
25             android:layout_height="wrap_content"
26             android:layout_marginTop="5dp"
27             android:layout_margin="0.5dp"
28             android:background="@drawable/importing"
29             android:width="100dp" />
30 
31         <Button
32             android:id="@+id/menu_btnCompany"
33             android:layout_width="wrap_content"
34             android:layout_height="wrap_content"
35             android:layout_marginTop="5dp"
36             android:background="@drawable/company"
37             android:layout_margin="0.5dp"
38             android:width="100dp" />
39     </LinearLayout>
40 
41     <LinearLayout
42         android:layout_width="match_parent"
43         android:layout_height="match_parent"
44         android:gravity="center_horizontal"
45         android:orientation="horizontal" >
46 
47         <Button
48             android:id="@+id/menu_btnCustom"
49             android:layout_width="wrap_content"
50             android:layout_height="wrap_content"
51             android:layout_margin="0.5dp"
52             android:layout_marginTop="5dp"
53             android:background="@drawable/customer"
54             android:width="100dp" />
55 
56         <Button
57             android:id="@+id/menu_btnTeSe"
58             android:layout_width="wrap_content"
59             android:layout_height="wrap_content"
60             android:layout_margin="0.5dp"
61             android:layout_marginTop="5dp"
62             android:background="@drawable/tese"
63             android:width="100dp" />
64 
65         <Button
66             android:id="@+id/menu_btnTool"
67             android:layout_width="wrap_content"
68             android:layout_height="wrap_content"
69             android:layout_margin="0.5dp"
70             android:layout_marginTop="5dp"
71             android:background="@drawable/setting"
72             android:width="100dp" />
73     </LinearLayout>
74 
75 </LinearLayout>
View Code

相关文章:

  • 2022-12-23
  • 2021-08-18
  • 2021-05-30
  • 2021-09-19
  • 2021-10-20
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-09
  • 2022-12-23
  • 2021-08-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-11
相关资源
相似解决方案