Android web browser slideshow and slideshow

I have a list of chapters on the list. When the user selects the section that he is expanding, and the subsections in this list of chapters. when the user selects a specific subtopic, its contents are loaded into webview on a new screen. all is good. But I want some functionality in webview. When the user moves the web view, the web view should move up, and a new web view from the bottom up should appear on the screen (slide animation in the web view) with the following subtopics. the same is the case when sliding down, when the user displaces the web view with the contents of the previous subtopics.

Please help how to provide slide shows and slide animations in web browsing. Thanks

+6
source share
2 answers

Apply animation to web view.

Slide down.xml

<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:fromYDelta="0%p" android:interpolator="@android:anim/accelerate_interpolator" android:toYDelta="100%p" android:duration="2000" /> </set> 

Slide Up.xml

 <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator"> <translate android:fromYDelta="100%" android:toXDelta="0" android:duration="1000" /> <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="500" /> </set> 

Use the Wbeview startAnimation Method

+12
source

pleas implements OnGestureListener in your activities

and use the following code

 detector = new GestureDetector(this, this); WebView1.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { detector.onTouchEvent(event); return true; } }); @Override public boolean onDown(MotionEvent e) { // TODO Auto-generated method stub return false; } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { float dX = e2.getX() - e1.getX(); float dY = e1.getY() - e2.getY(); // check is all completed or return with some condition if (Math.abs(dY) < SWIPE_MAX_OFF_PATH && Math.abs(velocityX) >= SWIPE_THRESHOLD_VELOCITY && Math.abs(dX) >= SWIPE_MIN_DISTANCE) { // logic for left and right if(dX>0){ } elseif(dX<0) } return false; } @Override public void onLongPress(MotionEvent e) { // TODO Auto-generated method stub } @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { // TODO Auto-generated method stub return false; } @Override public void onShowPress(MotionEvent e) { // TODO Auto-generated method stub } @Override public boolean onSingleTapUp(MotionEvent e) { // TODO Auto-generated method stub return false; } 

the fling method will handle the touch event if the direction is x, and you can make it work along the y axis.

+1
source

Source: https://habr.com/ru/post/903360/


All Articles