android 简单模仿IOS的3D Touch功能
2016-10-19 18:20
393 查看
个人对IOS端3D Touch功能很感兴趣,想来自己实现,上网一搜,这类文章并不是很多,于是想自己实现一个。在自己绞尽脑汁的时候在github上搜索到一个开源项目可以实现简单3D Touch功能,在此坐一下笔记,以供后续参考。
话不多说,贴出核心代码:
话不多说,贴出核心代码:
//设置PeekView选项 PeekViewOptions options = new PeekViewOptions(); options.setBackgroundDim(1f); // range: 0 - 1 (default is .6) 背景模糊度 options.setHapticFeedback(false); // default is true // it may be a good idea to set set these through resources so that you can use different options based on screen size and orientation options.setWidthPercent(.4f); // range: .1 - .9 (default is .6) options.setHeightPercent(.4f); // range: .1 - .9 (default is .5) // you can also set the size of the PeekView using absolute values, instead of percentages. // Setting these will override the corresponding percentage value. // You should use this instead of setting the size of the view from the layout resources, as those get overridden. options.setAbsoluteWidth(200); // 200 DP options.setAbsoluteHeight(200); // 200 DP // default is false. If you change this to true, it will ignore the width and height percentages you set. options.setFullScreenPeek(true); // default is true. Unless you are going to animate things yourself, i recommend leaving this as true. //options.setFadeAnimation(false); options.setUseFadeAnimation(true); // PeekView has the ability to blur the background behind it, instead of just using a simple dark dim. // If you set a blurred view, then it will invalidate whatever you set as your background dim. // If you do this, please look at the installation steps for the blur effect, or the app will crash. options.setBlurBackground(true); // default is true // options.setBlurOverlayColor(Color.parse("#99000000")); // #99000000 default options.setBlurOverlayColor(Color.parseColor("#99000000")); //背景颜色 //Peek.into(...).with(options).applyTo(...); Peek.into(R.layout.image_peek, new SimpleOnPeek() { @Override public void onInflated(View rootView) { WebView mWebView = (WebView) rootView.findViewById(R.id.mWebView); final ProgressBar mProgressBar = (ProgressBar) rootView.findViewById(R.id.mProgressBar); mWebView.loadUrl("http://www.baidu.com"); mWebView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return super.shouldOverrideUrlLoading(view, url); } }); mWebView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { if (newProgress==100) { mProgressBar.setVisibility(View.GONE); } else { mProgressBar.setVisibility(View.VISIBLE); } mProgressBar.setProgress(newProgress); super.onProgressChanged(view, newProgress); } }); } }).with(options).applyTo(this, baseView);
相关文章推荐
- Android调用系统相机拍照,并且模仿实现水印相机简单功能
- iOS开发 3D Touch的简单使用
- ios 简单模仿随便走的AR功能(原理)
- Android实现类似3D Touch菜单功能
- iOS 3D Touch功能
- iOS 3D Touch功能 3 -备
- IOS 3D Touch功能分析
- Android开发学习之路-3DTouch效果模仿
- iOS 3D Touch功能
- iOS 3D Touch功能
- ios 3D Touch功能的实现
- android listview仿iphone通讯录ios 3dTouch
- Android调用系统相机拍照,并且模仿实现水印相机简单功能
- ios 3D Touch功能的实现
- Android开发周报:Android N将引入3D Touch功能、官方MVP架构解析
- ios 3D Touch功能的实现
- IOS在Table View添加3D Touch功能
- ios 简单模仿随便走的AR功能一
- IOS 实现3D Touch在tableView的简单应用(swift版)
- IOS 实现3D Touch在tableView的简单应用