SlidingMenu开源库

听说学习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 {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.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>






评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值