侧滑菜单页面小程序
Ⅰ 怎么使用侧滑菜单SlidingMenu
看一下怎么使用吧!
/** SlidingMenu 常用属性介绍: */
menu.setMode(SlidingMenu.LEFT);//设置左滑菜单 SlidingMenu.RIGHT SlidingMenu.LEFT_RIGHT 右侧滑/左右侧滑
menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);//设置滑动的屏幕局限,该设置为全屏区域都可以滑动
menu.setShadowDrawable(R.drawable.shadow);//设置暗影
menu.setShadowWidthRes(R.dimen.shadow_width);//设置暗影的宽度
menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);//SlidingMenu划出时主页面显示的残剩宽度
menu.setBehindWidth(400);//设置SlidingMenu菜单的宽度
menu.setFadeDegree(0.35f);//SlidingMenu滑动时的渐变程度
menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);//使SlidingMenu附加在Activity上
menu.setMenu(R.layout.menu_layout);//设置menu的布局文件
menu.toggle();//动态断定主动封闭或开启SlidingMenu
menu.showMenu();//显示SlidingMenu
menu.showContent();//显示内容
menu.setOnOpenListener(onOpenListener);//slidingmenu打开关于封闭menu有两个,简单的来说,对于menu close事务,一个是when,一个是after
menu.OnClosedListener(OnClosedListener);//slidingmenu封闭时事务
menu.OnClosedListener(OnClosedListener);//slidingmenu封闭后事务
简单设置左方向菜单侧滑的使用方法:
public class SlidingExample extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle(R.string.attach);
// set the content view
setContentView(R.layout.content);
// configure the SlidingMenu
SlidingMenu menu = new SlidingMenu(this);
menu.setMode(SlidingMenu.LEFT);
menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
menu.setShadowWidthRes(R.dimen.shadow_width);
menu.setShadowDrawable(R.drawable.shadow);
menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
menu.setFadeDegree(0.35f);
menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
menu.setMenu(R.layout.menu);
}
}
如果你要设置左右菜单侧滑,看这里:
public class MainActivity extends FragmentActivity {
public SlidingMenu mSlidingMenu;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mSlidingMenu = new SlidingMenu(this);
mSlidingMenu.setMode(SlidingMenu.LEFT_RIGHT);
mSlidingMenu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
mSlidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
mSlidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
mSlidingMenu.setMenu(R.layout.slidemenu_primary);//左侧滑
mSlidingMenu.setSecondaryMenu(R.layout.slidemenu_secondery);//右侧滑
getSupportFragmentManager().beginTransaction().
replace(R.id.aty_main_framLayout, new ViewPagerFragment()).commit();
getSupportFragmentManager().beginTransaction().
replace(R.id.framLayout_fragment, new TranslationAnimationFragment()).commit();
}
/** 重写返回键和menu键,控制菜单侧滑关闭 */
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
if(mSlidingMenu.isMenuShowing())
mSlidingMenu.showContent();
else finish();
return true;
case KeyEvent.KEYCODE_MENU:
mSlidingMenu.showSecondaryMenu();
return true;
}
return super.onKeyDown(keyCode, event);
}
}
下面看一下如何解决侧滑跟ViewPager左右滑动的冲突:《当然,我的源码上展示了怎么使用》
mSlidingMenu.addIgnoredView(viewPager);
在你的Viewpager内容显示之前,调用上面的方法,就Ok了、
SlidingMenu.setTouchModeAbove().其中一共包含三中手势模式:
TOUCHMODE_FULLSCREEN 全屏模式,在正文布局中通过手势也可以打开SlidingMenu
TOUCHMODE_MARGIN 边缘模式,在正文布局的边缘处通过手势可以找开SlidingMenu
TOUCHMODE_NONE 自然是不能通过手势打开SlidingMenu了
当你在设置暗影时,在res/drawable/shadow.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:centerColor="#11000000"
android:endColor="#00000000"
android:startColor="#33000000" />
</shape>
转载仅供参考,版权属于原作者。祝你愉快,满意请点赞哦
代码很简单,就是通过open值控制view对类的选取
Ⅲ html5 浮动侧滑菜单栏怎样实现
一共有4种侧滑动画特效。这款CSS3菜单的特点是鼠标划过时即可以各种动画方式展开和隐藏菜单项,该动画方式由CSS3中的transition-delay属性来完成
<style type="text/css">
/*Fontawesome Iconfont*/
@import url(http://libs.useso.com/js/font-awesome/4.0.1/css/font-awesome.min.css);
@import url(http://fonts.useso.com/css?family=Montserrat);
* {margin: 0; padding: 0;}
li {list-style-type: none;}
.grid {float: left;width:980px;margin: 0 auto;}
.grid > li { width: 285px; height: 500px; overflow: hidden; float: left; margin: 20px 0 20px 30px; position: relative; }
.grid > li:hover {box-shadow: 0 0 15px 0 rgba(0, 0, 0, 0.5);}
.grid>li section {position: relative; transition: all 0.25s; width: 100%;}
.grid>li h2 {font: bold 14px montserrat; color: #fff; text-transform: uppercase; position: absolute; text-align: center; width: 60%; left: 20%; top: 100px; padding: 10px 0; border: 2px solid white; border-radius: 4px;}
.sidenav { position: absolute; top: 0; left: 0; bottom: 0; background: linear-gradient(rgba(50,60,60, 1), rgba(50,60,60, 0.7)); width: 50px; transition: all 0.25s; overflow: hidden; padding-top: 100px;}
.sidenav li { _overflow: hidden; width: 150px; }
.sidenav a { text-decoration: none; color: #eee; display: block; line-height: 48px; }
.sidenav span {display: block;}
.sidenav b { padding-left 10px; display: block; color: white; font-family: Montserrat; font-size: 12px; line-height: 4; opacity: 0; }
.sidenav a i { display: block; float: left; font-size: 16px; line-height: 48px; width: 50px; text-align: center; }
/*All instances*/
.grid>li:hover .sidenav {width: 150px;}
.grid>li:hover section {margin-left: 150px;}
.grid>li:hover b {opacity: 1;}
.sidenav li:nth-child(1) b, .sidenav li:nth-child(1) a {transition-delay: .08s;}
.sidenav li:nth-child(2) b, .sidenav li:nth-child(2) a {transition-delay: .16s;}
.sidenav li:nth-child(3) b, .sidenav li:nth-child(3) a {transition-delay: .24s;}
.sidenav li:nth-child(4) b, .sidenav li:nth-child(4) a {transition-delay: .32s;}
.sidenav li:nth-child(5) b, .sidenav li:nth-child(5) a {transition-delay: .40s;}
.sidenav li:nth-child(6) b, .sidenav li:nth-child(6) a {transition-delay: .48s;}
/*Three*/
.three .w {transform: perspective(100px) translateZ(-24px);}
.three b {transform: perspective(100px) rotateY(180deg) translateZ(24px) scale(0.5); }
.three:hover b {transform: perspective(100px) rotateY(0) translateZ(24px) scale(1); transition: all 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275); background: transparent;}
.three .sidenav {width: 150px;}
/*Two*/
.two .w {transform: perspective(100px) translateZ(-24px);}
.two b {transform: perspective(100px) rotateX(90deg) translateZ(24px) scale(1.5); opacity: 0; }
.two:hover b {transform: perspective(100px) rotateX(0) translateZ(24px) scale(1); transition: all .4s; opacity: 1;}
.two .sidenav {width: 150px;}
/*One*/
.one .w {transform: perspective(100px);}
.one b {transform: perspective(100px) rotateY(90deg); _opacity: 0; transform-origin: left center; _border: 1px solid white;}
.one:hover b {transform: perspective(100px) rotateX(0); transition: all .4s; opacity: 1;}
.one .sidenav {width: 150px;}
.one .sidenav span {float: left; width: 100px;}
</style>
<!--[if IE]>
<script src="http://libs.useso.com/js/html5shiv/3.7/html5shiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="htmleaf-container">
<header class="htmleaf-header bgcolor-11">
<div class="htmleaf-demo center">
<a href="index.html">DEMO1</a>
<a href="index2.html" class="current">DEMO2</a>
<a href="index3.html">DEMO3</a>
<a href="index4.html">DEMO4</a>
</div>
<div style="text-align:center;clear:both;">
<script src="/gg_bd_ad_720x90.js" type="text/javascript"></script>
<script src="/follow.js" type="text/javascript"></script>
</div>
</header>
<div class="htmleaf-content bgcolor-8">
<ul class="grid">
<li class="one">
<ul class="sidenav">
<li><a><i class="fa fa-check"></i><span class="w"><b>Tasks</b></span></a></li>
<li><a><i class="fa fa-inbox"></i><span class="w"><b>Messages</b></span></a></li>
<li><a><i class="fa fa-pencil"></i><span class="w"><b>New Post</b></span></a></li>
<li><a><i class="fa fa-cog"></i><span class="w"><b>Settings</b></span></a></li>
<li><a><i class="fa fa-star"></i><span class="w"><b>Starred</b></span></a></li>
<li><a><i class="fa fa-power-off"></i><span class="w"><b>Logout</b></span></a></li>
</ul>
<section>
<h2>Door Opening</h2>
<img src="img/mb1.png"/>
</section>
</li>
<li class="two">
<ul class="sidenav">
<li><a><i class="fa fa-check"></i><span class="w"><b>Tasks</b></span></a></li>
<li><a><i class="fa fa-inbox"></i><span class="w"><b>Messages</b></span></a></li>
<li><a><i class="fa fa-pencil"></i><span class="w"><b>New Post</b></span></a></li>
<li><a><i class="fa fa-cog"></i><span class="w"><b>Settings</b></span></a></li>
<li><a><i class="fa fa-star"></i><span class="w"><b>Starred</b></span></a></li>
<li><a><i class="fa fa-power-off"></i><span class="w"><b>Logout</b></span></a></li>
</ul>
<section>
<h2>Flip Down</h2>
<img src="img/mb2.png"/>
</section>
</li>
<li class="three">
<ul class="sidenav">
<li><a><i class="fa fa-check"></i><span class="w"><b>Tasks</b></span></a></li>
<li><a><i class="fa fa-inbox"></i><span class="w"><b>Messages</b></span></a></li>
<li><a><i class="fa fa-pencil"></i><span class="w"><b>New Post</b></span></a></li>
<li><a><i class="fa fa-cog"></i><span class="w"><b>Settings</b></span></a></li>
<li><a><i class="fa fa-star"></i><span class="w"><b>Starred</b></span></a></li>
<li><a><i class="fa fa-power-off"></i><span class="w"><b>Logout</b></span></a></li>
</ul>
Ⅳ 实现侧滑菜单使用 DrawerLayout和SlidingMenu有什么区别
slidingmenu 将view分为上下两层,上层是主页内容页而下一层才是菜单页。而drawerlayout的实现是刚好相反,上层是菜单下层是主页内容。一句话,就是slidingmenu是主页压菜单,drawerlayout是菜单压主页
Ⅳ 手机菜单页面侧滑(就是选中的功能,点了过后页面向左边滑过去就进入功能里面了),请问有没有这样的软件...
这种是手机操作系统不是软件主题啥的,一般手机没个功能,苹果手机的操作系统就是这样的
Ⅵ 小程序 顶部导航栏怎样做成可滑动
android4.0隐藏下方的导航栏用requestWindowFeature(Window.
Ⅶ 怎么制作微信小程序滑动下拉菜单
在公众平台,点击 自定义菜单 ,添加你想要的内容就可以,第一步设置 菜单名称,第二步设置 菜单内容,添加完了之后保存并发布,下拉菜单设置完成。
Ⅷ android中我使用了drawerlayout实现侧滑菜单,主界面是一个listview,为什么
给侧滑菜单布局添加属性android:clickable="true"
Ⅸ html5做手机app开发时有没有好的侧滑菜单插件
1.思路:
其时有2个WebView,一个main是用来装主页面,一个menu是用来装菜单(为提高性能,菜单项是采用了预加载方式的,预加载时为了避免和主页面争夺资源,采用延时加载,例如:
//plusReady事件后,自动创建menu窗口;
mui.plusReady(function() {
main = plus.webview.currentWebview();
//setTimeout的目的是等待窗体动画结束后,再执行create webview操作,避免资源竞争,导致窗口动画不流畅;
setTimeout(function () {
//侧滑菜单默认隐藏,这样可以节省内存;
menu = mui.preload({
id: 'offcanvas-drag-right-plus-menu',
url: 'offcanvas-drag-right-plus-menu.html',
styles: {
left: 0,
width: '70%'
}
});
},300);
});
2. 所谓侧滑,就是控制菜单WebView的显示,使用它的left来定位左边位置;
3. 要打开新的webView,要注意webview的show方法使用:
void plus.webview.show( id_wvobj, aniShow, ration, showedCB, extras );
参数含义:(1)是webview对象 (2)动画效果,从没显示过,一般用"none",(3)动画过渡时间 (4)当指定Webview窗口显示动画执行完毕时触发回调函数,窗口无动画效果(如"none"动画效果)时也会触发此回调。(5)传递的参数;
4.显示的方法:
(1)按钮点击后,让menu直接show出来,并对main设置样式,比如
menu.show("none",0,function(){
main.setStyle({
left:"70%",
transition:{
ration:150
}
});
});
(2)关闭侧滑菜单,实际就是设置main的样式了,比如:
main.setStyle({
left: '0',
transition: {
ration: 150
}
});
另外注意窗体切换完成后要关掉menu
//等窗体动画结束后,隐藏菜单webview,节省资源;
setTimeout(function() {
menu.hide();
}, 200);
5.被打开的WebView的界面如何控制关闭侧滑菜单:
(1)先要找到主页面,main = plus.webview.currentWebview().opener();
(2)激发主页面的某个事件,例如:mui.fire(main,"menu:swipeleft");