利用SlidingPaneLayout实验仿QQ侧滑效果

1.效果图

          

2.布局文件

 <?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SlidingPaneLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/slidingpanelayout"
android:layout_width="match_parent"
android:layout_height="match_parent"> <FrameLayout
android:layout_width="200dp"
android:layout_height="match_parent"> <LinearLayout
android:id="@+id/full_left"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:background="#65c7fa"
android:orientation="vertical"> <TextView
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#ffffff"
android:gravity="center"
android:text="我的功能标签"
android:textColor="#000000"
android:textSize="20sp"
android:textStyle="bold" /> <Button android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#65c7fa"
android:onClick="baidu"
android:text="百度"
android:textColor="#ffffff" /> <Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#65c7fa"
android:onClick="qq"
android:text="QQ"
android:textColor="#ffffff" /> <Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#65c7fa"
android:onClick="wangyi"
android:text="网易"
android:textColor="#ffffff" /> <Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#65c7fa"
android:onClick="sina"
android:text="新浪"
android:textColor="#ffffff" />
</LinearLayout>
</FrameLayout> <WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent" /> </android.support.v4.widget.SlidingPaneLayout>

3.Java代码

 import android.support.v4.widget.SlidingPaneLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.LinearLayout; public class MainActivity extends AppCompatActivity { SlidingPaneLayout mSlidingPaneLayout;
View mFullLeft; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); mSlidingPaneLayout = (SlidingPaneLayout) findViewById(R.id.slidingpanelayout);
mFullLeft = findViewById(R.id.full_left); mFullLeft.setAlpha(0);//默认 full侧栏隐藏 显示最小-预览式的侧栏 mWebView = (WebView) findViewById(R.id.webview); WebSettings settings = mWebView.getSettings();
settings.setJavaScriptEnabled(true);
WebViewClient client = new WebViewClient();
mWebView.setWebViewClient(client); mSlidingPaneLayout.setPanelSlideListener(new SlidingPaneLayout.PanelSlideListener() {
@Override
public void onPanelSlide(View panel, float slideOffset) {
//slideOffset: close left->open left from 0-1
System.out.println("slide" + slideOffset);
//view.setalpha(0~1)
//full完全显示时small就应完全不可见
mFullLeft.setAlpha(slideOffset);
} @Override
public void onPanelOpened(View panel) {
System.out.println("opened");
} @Override
public void onPanelClosed(View panel) {
System.out.println("closed");
}
});
} WebView mWebView; public void baidu(View view) {
mWebView.loadUrl("http://www.baidu.com");
} public void qq(View view) {
mWebView.loadUrl("http://www.qq.com");
} public void wangyi(View view) {
mWebView.loadUrl("http://www.163.com");
} public void sina(View view) {
mWebView.loadUrl("http://www.sina.com");
}
}

有借鉴别人的代码,但忘记博主啦,请见谅!!!

利用SlidingPaneLayout实现侧滑的更多相关文章

  1. Android中禁止SlidingPaneLayout的侧滑功能

    Android中使用android.support.v4.widget.SlidingPaneLayout实现侧滑功能的时候,可能出现滑动屏幕时与SlidingPaneLayout的侧滑发生冲突,查看 ...

  2. 淘宝(阿里百川)手机客户端开发日记第三篇 SlidingPaneLayout实现侧滑菜单

    需要的三个布局文件: activity_main.xml :主窗体布局 left.xml : 左侧栏目分类布局 right.xml : 右侧内容详情 需要的组件: android.support.v4 ...

  3. 利用 MUI开发app, 如何实现侧滑菜单及其主体部分上下滑动

     利用mui开发APP 之侧滑菜单主内容滚动问题 MUI作为开发者常用的框架之一,其号称最接近原生APP体验的高性能前端框架.因此利用mui开发移动APP,可以为开发者提供很大的便利和接近原生的体验. ...

  4. 在 Swift 项目中实现侧滑菜单-利用 SWRevealViewController

    你可以完全自己手动写一个侧滑菜单,但是现在在 GitHub 上面已经有很多免费的开源库了,如果不是有很特别的需求,大可不必新建一个轮子. 在这里我使用的这个第三方库名字叫做 SWRevealViewC ...

  5. 利用开源SlidingMenu框架实现左右侧滑菜单的功能

    package com.loaderman.slidingmenudemo; import android.os.Bundle; import android.support.v4.app.Fragm ...

  6. 史上最简单,一步集成侧滑(删除)菜单,高仿QQ、IOS。

    重要的话 开头说,not for the RecyclerView or ListView, for the Any ViewGroup. 本控件不依赖任何父布局,不是针对 RecyclerView. ...

  7. 一行代码,让你的应用中UIScrollView的滑动与侧滑返回并存

    侧滑返回是iOS系统的一个很贴心的功能,特别是在大屏手机上,单手操作的时候去按左上角的返回键特别不方便.当我在使用一个APP的时候,如果控制器不能侧滑返回,我会觉得这个APP十分不友好...这款产品在 ...

  8. MUI - 侧滑菜单

    各大APP必备的侧滑菜单栏,支持手势滑动.包含QQ式.美团式等 结构模板 这里是示例Html, 必须使用Mui框架才能使用. 主容器 <div class="mui-off-canva ...

  9. android侧滑菜单笔记

    一.SlidingPaneLayout v4包下的控件,使用简单,功能简洁.官方文档明确说明该控件只能左侧滑动.使用如下: <android.support.v4.widget.SlidingP ...

随机推荐

  1. php SimpleXML 例子

    $txt = GetRemoteText($url); if(strlen($txt) > 0) { $xml = simplexml_load_string($txt); //获取xml if ...

  2. javaEE中关于dao层和services层的理解

    javaEE中关于dao层和services层的理解 入职已经一个多月了,作为刚毕业的新人,除了熟悉公司的项目,学习公司的框架,了解项目的一些业务逻辑之外,也就在没学到什么:因为刚入职, 带我的那个师 ...

  3. linux故障判断

    系统问题: 带宽 netstat cpu io 磁盘 内存     free ------------------------------------------------------------- ...

  4. 在CentOS或RHEL防火墙上开启端口

    转载自:https://linux.cn/article-4243-1.html 如果希望在服务器上提供服务,诸如CentOS或RHEL的企业级Linux发行版包含内置的强大防火墙,它们默认的防火墙规 ...

  5. 关于Delphi中多线程传递参数的简单问题

    http://bbs.csdn.net/topics/390513469/ unit uThread; interface uses Classes; type Th = class(TThread) ...

  6. dedecms后台验证码显示不正常的四种处理办法

    验证码不正确解决方法 分为两类解决方法 第一类:取消掉验证码,直接登录 第二类:修复验证码,回复验证码功能 四种常见的处理办法如下: 第一种:取消掉验证码具体方法如下 实现的方法一共分为两步来进行: ...

  7. C#学习网站记录

    C# 编程指南--Microfsoft官方C#编程指南 https://msdn.microsoft.com/zh-cn/library/67ef8sbd(v=vs.100).aspx

  8. SQL Server附加数据库出现错误5123的正确解决方法

    因为自己有一本基于SQL Server 2005的数据库教程,里边使用的示例数据库是AdventureWorks for SQL Server 2005,而我的机子上装的是SQL Server 200 ...

  9. 巧用vsprintf将浮点数等转化字符串

    直接上代码 #include <stdarg.h> ]; int vspf(char *fmt, ...) { va_list argptr; int cnt; va_start(argp ...

  10. springboot 使用c3p0数据库连接池的方法

    使用springboot开发时,默认使用内置的tomcat数据库连接池,经常碰到这种情况:运行时间一长,数据库连接中断了.所以使用c3p0连接池吧. 引入的maven依赖: <dependenc ...