This project is aimed to implement 3D style page flip on Android system based on OpenGL 2.0.
For JNI version, please visit: android-PageFlip-JNI
Add it to your build.gradle with:
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
and:
dependencies {
compile 'com.github.eschao:android-PageFlip:1.0.2'
}
The following versions have been tested on emulator:
Android version | API version | Support |
---|---|---|
3.2 | API 13 | x |
4.1 | API 16 | √ |
4.2 | API 17 | √ |
4.3 | API 18 | √ |
4.4 | API 19 | √ |
5.0 | API 21 | √ |
5.1 | API 22 | √ |
6.0 | API 23 | √ |
7.0 | API 24 | √ |
7.1.1 | API 25 | √ |
7.+ | API 26 | √ |
Creates a surface view class extending from GLSurfaceView
Implements android Renderer interface to draw your content on a bitmap and set it as a texture of PageFlip
Instanitiates a PageFlip object in the constructor of your surface view
Configures PageFlip, For example: set animating duration, page mode or mesh pixels
Handles the below android events:
You may need a message handler to send/receive an drawing message. Please refer to PageFlipView in sample application.
You may need a lock to avoid conflicts between main thread and OpenGL rendering thread. Please refer to PageFlipView in sample application.
More details, please take a look PageFlipView in sample application.
PageFlip library provides some configurations for customizing its behaviors. For example: shadow color and alpha, mesh pixels and page mode.
There are two page modes provided by PageFlip:
You can use enableAutoPage to enable auto page mode or disable it(equally enable single page mode).
Example:
// enable auto page mode
mPageFlip.enableAutopage(true);
You can enable/disable clicking screen to flip
Example:
// enable clicking to flip
mPageFlip.enableClickToFlip(true);
You can give a ratio of page width from 0 to 0.5f to set an area for reponsing click event to trigger a page flip. The default value is 0.5f, which means the backfward flip will happen if you click the left half of screen and forward flip will start if you click the right half of screen in single page mode.
Example:
// set ratio with 0.3
mPageFlip.setWidthRatioOfClickToFlip(0.3f);
You can set a listener to tell PageFlip if the forward flip or backward flip could happen.
Example:
mPageFlip.setListener(mListener);
Set how many pixels are used for a mesh. The less pxiels the mesh uses, the more fine the drawing is and the lower the performance is. The default value is 10 pixels.
Example:
mPageFlip.setPixelsOfMesh(5);
When page is curled, it is actually tackled as a semi-cylinder by PageFlip. You can set size of the semi-cylinder to change the flip shap. Since the semi-cylinder dependeds on the line length from the touch point to original point(see the below illustration), you need to provide a ratio of this line length to tell PageFlip the peremeter of the semi-cylinder. The default value is 0.8f.
+----------------+
| touchP |
| . |
| \ |
| + p0 |
| \ |
| \ |
| p1 + |
| \ |
+----------------+
original point, that means you drag the page from here to touch point(touchP)
The length from p0 to p1 is peremeter of semi-cylinder and determined by ratio your giving
Example:
mPageFlip.setSemiPerimeterRatio(0.6f);
You can set the mask alpha for the back of fold page when page is curled in single page mode. The default value is 0.6f.
Example:
mPageFlip.setMaskAlphaOfFold(0.5f);
You can set start/end color and start/end alpha for edge shadow of fold page.
Example:
// set start color with 0.1f, start alpha with 0.2f, end color with 0.5f
// and end alpha with 1f
mPageFlip.setShadowColorOfFoldBase(0.1f, 0.2f, 0.5f, 1f);
You can set start/end color and start/end alpha for base shadow of fold page.
Example:
mPageFlip.setShadowColorOfFoldBase(0.05f, 0.2f, 0.5f, 1f);
When page is curled, the size of fold page will follow the finger movement to be changed and its edge shadow width should be changed accordingly. You can set an appropriate width range for shadow width.
Example:
// set the minimal width is 5 pixels and maximum width is 40 pixels.
// set the ratio is 0.3f which means the width will be firstly computed by formula:
// width = diameter of semi-cylinder * 0.3f, and then compare it with minimal
// and maximal value to make sure the width is in range.
mPageFlip.setShadowWidthOfFoldEdges(5, 40, 0.3f);
Like Edge shadow width of fold page, You can set an appropriate width range for base shadow of fold page.
Example:
// see {@link #setShadowWidthOfFoldEdges} function
mPageFlip.setShadowWidthOfFoldBase(5, 40, 0.4f);
You can give a duration for flip animating when you call onFingerUp function to handle the finger up event.
Example:
// the last parameter is duration with millisecond unit, here we set it with 2 seconds.
mPageFlip.onFingerUp(x, y, 2000);
This project is licensed under the Apache License Version 2.0.
JNI绑定 Android上的Java资源 WebView代码组织
Native.js for Android封装一条通过JS语法直接调用Native Java接口通道,通过plus.android可调用几乎所有的系统API。 方法: currentWebview: 获取当前Webview窗口对象的native层实例对象 newObject: 创建实例对象 getAttribute: 获取对象(类对象/实例对象)的属性值 setAttribute: 设置对象(类对
Android++ 是一个免费的 Visual Studio 扩展,用于支持在 Visual Studio 上开发和调试原生的 Android 应用,主要基于 NDK 的 C/C++ 应用。同时包括可订制的发布、资源管理以及集成了 Java 源码编译。
Android(安卓)是一种基于Linux内核的自由及开放源代码的操作系统,主要使用于移动设备,如智能手机和平板电脑,由美国谷歌公司和开放手机联盟领导及开发。Android操作系统最初由Andy Rubin开发,主要支持手机。2005年8月由谷歌收购注资。2007年11月,谷歌与84家硬件制造商、软件开发商及电信营运商组建开放手机联盟共同研发改良Android系统。随后谷歌以Apache许可证的授
Android(安卓)是一种基于Linux内核的自由及开放源代码的操作系统,主要使用于移动设备,如智能手机和平板电脑,由美国谷歌公司和开放手机联盟领导及开发。Android操作系统最初由Andy Rubin开发,主要支持手机。2005年8月由谷歌收购注资。2007年11月,谷歌与84家硬件制造商、软件开发商及电信营运商组建开放手机联盟共同研发改良Android系统。随后谷歌以Apache许可证的授
简介 该库提供J2SE的Swing、AWT等类的安卓实现,引用该库便能在Android上运行J2SE应用程序。 该库实现大多数必需功能,但不是全部的J2SE。 成功示例HomeCenter服务器,该服务器基于J2SE,同时完全运行于Android之上。 使用指引 该库依赖于开源工程HomeCenter。 它不含Activity,需另建Android工程,并引用本库。 Activity和res需作为
前言 少年时我们追求激情,成熟后却迷恋平庸,在我们寻找,伤害,背离之后,还能一如既往的相信爱情,这是一种勇气,每个人都有属于自己的一片森林,迷失的人迷失了,相逢的人会再相逢。 没有人觉得自己差人一等,也没有人一直喜欢居于他人之下,身为一个Android程序员,只有不断的学习,不断的付出自己的努力,自己的汗水,自己的时间,才能让自己进步,学无止境。就上篇而言,我接着来讲一下Android面试时And
我的应用程序上有WebView,我在android 7.0上从用户那里得到了许多相同的错误,同时膨胀了WebView片段。 错误日志: Android看法充气异常:二进制XML文件行#8:二进制XML文件行#8:错误充气类android。网络工具包。网络视图导致:android。看法充气异常:二进制XML文件行#8:充气类android时出错。网络工具包。网络视图 网络视图片段布局: 我从这些设备