SlidingMenu开源库

来源:互联网 发布:乐1pro刷机包优化内核 编辑:程序博客网 时间:2024/06/05 11:17

听说学习Android和写CSDN博客更配哦,那从今天起就开始我的博客生涯啦,希望早日从菜鸟变为大神~~~得意

今天学习的内容是SlidingMenu,这是一个开源库,源码地址在github上,下载地址 https://github.com/jfeinstein10/SlidingMenu,另外一个开源库ActionBarSherlock,下载地址 https://github.com/jakewharton/ActionBarSherlock

自己新建的工程需要导入SlidingMenu中的和ActionBarSherlock中的这两个依赖工程


极客学院的视频教程地址 http://www.jikexueyuan.com/course/61.html

Simple Example

package com.hexia.usingslidingmenu;import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;import android.app.Activity;import android.os.Bundle;public class MainActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);setContentView(R.layout.activity_main);SlidingMenu menu = new SlidingMenu(this);                menu.setMode(SlidingMenu.LEFT);                menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);                menu.setMenu(R.layout.slidingmenu);                menu.setShadowWidthRes(R.dimen.shadow_width);                menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);                menu.setFadeDegree(0.35f);                menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);}}

activity_main.xml

<pre name="code" class="html"><?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="match_parent"    android:orientation="vertical" ></LinearLayout>

slidingmenu.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="match_parent"    android:background="#ff999999"    android:orientation="vertical" >        <com.jeremyfeinstein.slidingmenu.lib.SlidingMenu         xmlns:sliding="http://schemas.android.com/apk/res-auto"        android:id="@+id/slidingmenulayout"        android:layout_width="fill_parent"        android:layout_height="fill_parent"        sliding:fadeEnabled="true"        sliding:selectorEnabled="true">                <LinearLayout             android:layout_width="match_parent"            android:layout_height="match_parent"            android:orientation="vertical" >                        <Button             android:layout_width="fill_parent"            android:layout_height="wrap_content"            android:text="Click me"/>            <TextView             android:layout_width="fill_parent"            android:layout_height="wrap_content"            android:text="Learn slidingmenu"/>        </LinearLayout>            </com.jeremyfeinstein.slidingmenu.lib.SlidingMenu></LinearLayout>

dimens.xml

<?xml version="1.0" encoding="utf-8"?><resources>    <dimen name="shadow_width">50dp</dimen>    <dimen name="slidingmenu_offset">200dp</dimen></resources>






0 0
原创粉丝点击