Android实现模仿UCweb菜单效果的方法

2019-12-10 19:59:23刘景俊

易采站长站为您分析Android实现模仿UCweb菜单效果的方法,较为详细的分析了Android模仿UCweb菜单效果的页面布局及功能实现技巧,具有一定参考借鉴价值,需要的朋友可以参考下

本文实例讲述了Android实现模仿UCweb菜单效果的方法。。具体如下:

UCWeb的菜单看起来不错,自己模仿做一个,思路实现如下:

1、保留menu按键作用

2、用popupwindow作为菜单显示容器

3、用GridView显示所有子菜单

代码如下:

1、布局文件:

popupwindow.xml:

 

 
  1. <?xml version="1.0" encoding="utf-8"?>  <LinearLayout 
  2. xmlns:android="http://www.easck.com/apk/res/android"  android:layout_width="fill_parent" 
  3. android:background="#50000000"  android:layout_height="fill_parent" 
  4. android:gravity="bottom|center_horizontal">  <LinearLayout 
  5. xmlns:android="http://www.easck.com/apk/res/android"  android:layout_width="320dip" 
  6. android:background="@drawable/bkg2"  android:id="@+id/popdialog" 
  7. android:layout_height="250dip"  android:gravity="center_vertical|center_horizontal" 
  8. >  <GridView 
  9. android:id="@+id/gridview"  android:layout_width="fill_parent" 
  10. android:layout_height="fill_parent"  android:numColumns="4" 
  11. android:verticalSpacing="10dip"  android:horizontalSpacing="10dip" 
  12. android:stretchMode="columnWidth"  android:gravity="center" 
  13. />  </LinearLayout> 
  14. </LinearLayout>