Android侧滑菜单

 自定义属性:1.书写xml文件       values/attr.xml
                       2.在布局文件中进行使用,特别注意xmlns
                       3.在构造方法中(3个参数的构造方法)中获取我们设置的值

 

自定义View   1.onMeasure决定内部View(子view)的宽和高,以及自己的宽和高  

                      2.onLayout 决定子View的放置的位置
                      3.onTouchEvent添加点击事件

动画效果使用:nineoldandroids.jar

废话不多说了,上代码,随便写的,很low但是基本上的功能都有了:

主布局:activity_main.xml

    xmlns:tools="http://schemas.android.com/tools"
    xmlns:hello="http://schemas.android.com/apk/res/com.my.slidingmenu"      添加
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

   
            android:id="@+id/menu"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        hyman:rightPadding="100dp">
       
                    android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="horizontal">
           
           
           
                            android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/ic_launcher">
               

你可能感兴趣的:(Android)