我正在生成一种书籍应用程序,它可以显示一个页面WebView
.我有Next/Previous ImageButtons
和a GestureOverlay
来检测左/右滑动.当我想要更改页面时,我打电话:
private void changePage(int delta) {
currentPageIndex = currentPageIndex + delta;
if (currentPageIndex < 0) {
// negative index
currentPageIndex = 0;
} else if (currentPageIndex >= listOfPages.length) {
// index requested is out of range of the list
currentPageIndex = listOfPages.length - 1;
} else {
// set values for page load
filename = listOfPages[currentPageIndex];
mWebView.loadUrl("file:///android_asset/" + filename);
}
}
Run Code Online (Sandbox Code Playgroud)
'listOfPages'是我的文件名的字符串数组,loadUrl()工作得很好,但有没有人知道能够进行页面转换以模拟简单的页面转换?
chi*_*s54 11
如果有人有兴趣,我找到了办法.我定义了Animation
变量:
Animation slideLeftAnimation = AnimationUtils.loadAnimation(getBaseContext(), R.anim.slide_left);
Animation slideRightAnimation = AnimationUtils.loadAnimation(getBaseContext(), R.anim.slide_right);
Run Code Online (Sandbox Code Playgroud)
而slide_left
和slide_right
XML文件是从Android的API教程.
然后,对于左或右滑动,我mWebView.startAnimation(leftOrRightAnimation);
在mWebView.loadUrl(url);
通话前使用过.
希望这有助于其他任何人!
克里斯
归档时间: |
|
查看次数: |
5748 次 |
最近记录: |