Skip to content

renannery/TouchFeedback

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TouchFeedback | Data Binding

This example shows how to add a custom attribute in regular Views for TouchFeedback effects using Android Data Binding.

In the class Bindings.java there is a method called "touchFeedback" that can be used in XML layout without a CustomView and set a touch feedback for views like:

  • RelativeLayout
  • ImageView
  • LinearLayout

The method "touchFeedback" has a ColorDrawable parameter that will be the feedback color.

<ImageView
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:layout_weight="1"
    android:background="#F44336"
    android:scaleType="center"
    android:src="@mipmap/ic_launcher"
    app:touchFeedback="@{@color/md_light_blue_A100}" />

The feedback effect for API >= 21 (LOLLIPOP) is a Ripple Effect and for older versions is a selector with a smooth transaction between states

Demo TouchFeedback

I wrote a post about it as well https://developer.beer/touch-feedback-with-android-data-binding-3cffbc9d3ad8?gi=af725482d218#.61vh0e2uv

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages