Android gestures. Стандартные жесты

Содержание

Слайд 2

Стандартные жесты Операционная система Android содержит готовые классы для распознавания стандартных

Стандартные жесты

Операционная система Android содержит готовые классы для распознавания стандартных жестов

при работе с сенсорными экранами. К жестам относят самые разнообразные действия пользователя: простое касание экрана (например, при нажатии на кнопку), длительное прикосновение, двойное касание, касание экрана с последующим движением по экрану (свайпы, броски, перетягивания, перелистывания страниц), мультитач, растягивания или сжимания изображения двумя пальцами («щепотка») и тп.

https://material.google.com/patterns/gestures.html

Слайд 3

OnTouchListener Любая вьюшка может имплементировать этот интерфейс Метод-обработчик во втором аргументе

OnTouchListener

Любая вьюшка может имплементировать этот интерфейс
Метод-обработчик во втором аргументе содержит всю

необходимую информацию о касании: координаты по X и Y, а также тип события – нажатие, движение или отпускание
Пример кода: https://git.io/vPPNG
Слайд 4

Мультитач Android умеет обрабатывать до 10 касаний одновременно. Есть мнение, что

Мультитач

Android умеет обрабатывать до 10 касаний одновременно. Есть мнение, что это

как-то связано с количеством пальцев на руках ☺ Важно учитывать, что далеко не все устройства поддерживают 10 касаний!
К событиям ACTION_DOWN, ACTION_MOVE и ACTION_UP добавляются ACTION_POINTER_DOWN и ACTION_POINTER_UP.
ACTION_DOWN – срабатывает при касании первого пальца
ACTION_POINTER_DOWN – срабатывает при касании каждого последующего пальца
ACTION_MOVE – срабатывает при любом движении
ACTION_ POINTER_UP – срабатывает при отпускании каждого пальца кроме последнего
ACTION_UP – срабатывает при отпускании последнего пальца
Пример кода: https://git.io/vPPh0
Слайд 5

Класс GestureDetector A "touch gesture" occurs when a user places one

Класс GestureDetector

A "touch gesture" occurs when a user places one or

more fingers on the touch screen, and your application interprets that pattern of touches as a particular gesture. When a user places one or more fingers on the screen, this triggers the callback onTouchEvent() on the View that received the touch events. For each sequence of touch events (position, pressure, size, addition of another finger, etc.) that is ultimately identified as a gesture, onTouchEvent() is fired several times.
Android provides the GestureDetector class for detecting common gestures. Some of the gestures it supports include onDown(), onLongPress(), onFling(), and so on. You can use GestureDetector in conjunction with the onTouchEvent() method.
Пример кода: https://git.io/vPyIl

https://developer.android.com/training/gestures/detector.html

Слайд 6

Swipe Gallery Пример приложения, использующего свайпы: https://git.io/vPyty

Swipe Gallery

Пример приложения, использующего свайпы:
https://git.io/vPyty

Слайд 7

Класс ScaleGestureDetector https://git.io/vPyqq

Класс ScaleGestureDetector
https://git.io/vPyqq

Слайд 8

Перетаскивание вьюшек https://git.io/vPyq0

Перетаскивание вьюшек
https://git.io/vPyq0

Слайд 9

Домашнее задание Реализовать игру Алхимик. Поиграть можно здесь: http://www.yaplakal.com/fun/alchemy.html

Домашнее задание

Реализовать игру Алхимик.
Поиграть можно здесь: http://www.yaplakal.com/fun/alchemy.html

Слайд 10

Библиотеки для жестов https://github.com/Almeros/android-gesture-detectors https://github.com/aglover/gesticulate https://github.com/daimajia/AndroidSwipeLayout https://github.com/pedrovgs/DraggablePanel https://github.com/chrisbanes/PhotoView https://github.com/umano/AndroidSlidingUpPanel

Библиотеки для жестов

https://github.com/Almeros/android-gesture-detectors
https://github.com/aglover/gesticulate
https://github.com/daimajia/AndroidSwipeLayout
https://github.com/pedrovgs/DraggablePanel
https://github.com/chrisbanes/PhotoView
https://github.com/umano/AndroidSlidingUpPanel

Слайд 11

Дополнительная информация https://developer.android.com/training/gestures/index.html https://material.google.com/patterns/gestures.html https://guides.codepath.com/android/Gestures-and-Touch-Events https://code.tutsplus.com/tutorials/android-sdk-detecting-gestures--mobile-21161 https://www.sitepoint.com/android-gestures-and-touch-mechanics/ https://www.tutorialspoint.com/android/android_gestures.htm https://habrahabr.ru/post/120931/ http://developer.alexanderklimov.ru/android/views/imageswitcher.php

Дополнительная информация

https://developer.android.com/training/gestures/index.html
https://material.google.com/patterns/gestures.html
https://guides.codepath.com/android/Gestures-and-Touch-Events
https://code.tutsplus.com/tutorials/android-sdk-detecting-gestures--mobile-21161
https://www.sitepoint.com/android-gestures-and-touch-mechanics/
https://www.tutorialspoint.com/android/android_gestures.htm
https://habrahabr.ru/post/120931/
http://developer.alexanderklimov.ru/android/views/imageswitcher.php