基本信息
源码名称:android 侧滑菜单例子源码下载
源码大小:1.98M
文件格式:.zip
开发语言:Java
更新时间:2015-05-14
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍


package com.example.slidingmenudemo;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;

import com.slidingmenu.lib.SlidingMenu;

public class LeftAndRightActivity extends Activity {
	
	/**
	 * SlidingMenu 
	 * 
    viewAbove - a reference to the layout that you want to use as the above view of the SlidingMenu
    viewBehind - a reference to the layout that you want to use as the behind view of the SlidingMenu
    touchModeAbove - an enum that designates what part of the screen is touchable when the above view is showing. Margin means only the left margin. Fullscreen means the entire screen. Default is margin.
    behindOffset - a dimension representing the number of pixels that you want the above view to show when the behind view is showing. Default is 0.
    behindWidth - a dimension representing the width of the behind view. Default is the width of the screen (equivalent to behindOffset = 0).
    behindScrollScale - a float representing the relationship between the above view scrolling and the behind behind view scrolling. If set to 0.5f, the behind view will scroll 1px for every 2px that the above view scrolls. If set to 1.0f, the behind view will scroll 1px for every 1px that the above view scrolls. And if set to 0.0f, the behind view will never scroll; it will be static. This one is fun to play around with. Default is 0.25f.
    shadowDrawable - a reference to a drawable to be used as a drop shadow from the above view onto the below view. Default is no shadow for now.
    shadowWidth - a dimension representing the width of the shadow drawable. Default is 0.
    fadeEnabled - a boolean representing whether or not the behind view should fade when the SlidingMenu is closing and "un-fade" when opening
    fadeDegree - a float representing the "amount" of fade. 1.0f would mean fade all the way to black when the SlidingMenu is closed. 0.0f would mean do not fade at all.
    selectorEnabled - a boolean representing whether or not a selector should be drawn on the left side of the above view showing a selected view on the behind view.
    selectorDrawable - a reference to a drawable to be used as the selector NOTE : in order to have the selector drawn, you must call SlidingMenu.setSelectedView(View v) with the selected view. Note that this will most likely not work with items in a ListView because of the way that Android recycles item views.

	 */

	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		  final SlidingMenu menu = new SlidingMenu(this);
	        Button button = new Button(this);
	        button.setText("left");
	        button.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					 menu.showMenu();
				}
			});
	        
	        Button button2 = new Button(this);
	        button2.setText("right");
	        button2.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					 menu.showSecondaryMenu();
				}
			});
	        RelativeLayout view = new RelativeLayout(this);
	        LayoutParams llp = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
	        llp.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
	        view.addView(button,llp);
	        LayoutParams rlp = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
	        rlp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
	        view.addView(button2,rlp);
	        setContentView(view);
	        
	        menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
	        menu.setShadowWidthRes(R.dimen.shadow_width);
	        menu.setShadowDrawable(R.drawable.shadow);
	        menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
	        menu.setBehindWidth(200);
	        menu.setFadeDegree(0.35f);
	        menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
	        menu.setMenu(R.layout.activity_main);
	        
	        menu.setMode(SlidingMenu.LEFT_RIGHT);
	        menu.setSecondaryMenu(R.layout.activity_main);
			menu.setSecondaryShadowDrawable(R.drawable.shadow);
			menu.setShadowDrawable(R.drawable.shadow);
			
			
	}


}