Skip to content
how to capture swipes over a set of radio buttons that also capture clicks
Java
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea
app
gradle/wrapper
.gitignore
LICENSE
README.md
android-studio-design-view-layout.png
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle

README.md

Swipe Over Buttons Demo

In this demo, four radio buttons are registered to receive clicks. When clicked, the background color changes.

In addition, there's a secret left-to-right swipe action that causes the background to turn black. The swipe must go over the radio buttons and not vertically outside of them to work! The individual radio buttons get onClickListeners and the application itself receives onTouchEvents to check for the correct swipe.

layout view

This is what the application looks like in Android Studio's design view. There's a white frame indicating the LinearLayoutaround the radio buttons.

layout design view

The boundaries of the LinearLayout are computed after the application's view is "inflated". This is the point when the boundaries can be measured correctly. Then, it's just a matter of checking to make sure the user's swipe does not stray outside the vertical bounds of the layout.

Thanks!

Thanks to inky2010 for making the flower images available in the public domain!

You can’t perform that action at this time.