Giter Club home page Giter Club logo

material-ripple's Introduction

⚠️ The project is deprecated ⚠️

Any issues or pull requests will not be addressed. Please consider forking your own version if changes are needed.

Material Ripple Layout

Ripple effect wrapper for Android Views

Demo Image

Including in your project

compile 'com.balysv:material-ripple:1.0.2'

Check for latest version number on the widget below or visit Releases

Maven Central

Usage

Use static initializer on your View (see xml attributes below for customization)

MaterialRippleLayout.on(view)
           .rippleColor(Color.BLACK)
           .create();

Or wrap your View with MaterialRippleLayout in your layout file:

<com.balysv.materialripple.MaterialRippleLayout
    android:id="@+id/ripple"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="Button inside a ripple"/>

</com.balysv.materialripple.MaterialRippleLayout>

If using in an AdapterView you must set rippleInAdapter to true

Configure using xml attributes or setters in code:

app:mrl_rippleOverlay="true"              // if true, ripple is drawn in foreground; false - background
app:mrl_rippleColor="#ff0000"             // color of ripple
app:mrl_rippleAlpha="0.1"                 // alpha of ripple
app:mrl_rippleDimension="10dp"            // radius of hover and starting ripple
app:mrl_rippleHover="true"                // if true, a hover effect is drawn when view is touched
app:mrl_rippleRoundedCorners="10dp"       // radius of corners of ripples. Note: it uses software rendering pipeline for API 17 and below
app:mrl_rippleInAdapter="true"            // if true, MaterialRippleLayout will optimize for use in AdapterViews
app:mrl_rippleDuration="350"              // duration of ripple animation
app:mrl_rippleFadeDuration="75"           // duration of fade out effect on ripple
app:mrl_rippleDelayClick="true"           // if true, delays calls to OnClickListeners until ripple effect ends
app:mrl_rippleBackground="#FFFFFF"        // background under ripple drawable; used with rippleOverlay="false"
app:mrl_ripplePersistent="true"           // if true, ripple background color persists after animation, until setRadius(0) is called

Set an OnClickListener to MaterialRippleLayout:

findViewById(R.id.ripple).setOnClickListener(new View.OnClickListener() {
    @Override public void onClick(View v) {
        // handle me 
    }
});

Or if using in an AdapterView, simply use OnItemClickListener

Support for Android api versions < 14

For those unlucky developers that need to support older versions than 14, there's a way to do it.

You can use this library in addition with Jake Wharton's animation backport (http://nineoldandroids.com/) changing the imports from import android.animation.*; to: import com.nineoldandroids.animation.*; , import android.util.Property; to import com.nineoldandroids.util.Property; and in MaterialRippleLayout.java file, calling function shouldDelayChildPressedState() only if you're using api greater than 14.

Developed By

Balys Valentukevicius

License

Copyright 2015 Balys Valentukevicius

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

material-ripple's People

Contributors

ashqal avatar balysv avatar dlazaro66 avatar ivbaranov avatar tbarthel-fr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

material-ripple's Issues

Child view's onClickListener within MaterialRippleLayout doesn't work

Hi,
I have custom list adapter of list view where each row is instantiated within "getView(int position, View convertView, ViewGroup parent)" method. The root view of each row is "MaterialRippleLayout" and it has some child views. There I set some click listener of child views. But "onClick(View v)" method is not being called when child view is clicked.

TODO List

Feature backlog:

  • Implement a callback or post onClick() when Ripple animation ends so one can start heavy UI operations after. For example ListView item click and a transition to another screen.
  • Persistent Ripple effect flag (does not fade out and remains coloured)
  • Fix AdapterView onItemClickListener when MaterialRippleLayout is a item container
  • rippleFade attributes to control duration and strength of fade out effect

onItemClick is called after onItemLongClick in ListView

Hi,

At first, thank you for the awesome library!
I tried it in a ListView with setting app:rippleInAdapter="true",
When I long click on an item in the list, the listener correctly called but immediately after releasing touch (MotionEvent.ACTION_UP) the onItemClick method of OnItemClickListener get called! even if returning true in onItemLongClick method!

I've tested it with a normal FrameLayout and it hasn't any problem...

I suggest you forget about LongClick in your click handling mechanism for the layout...

endless loop in rippleInAdapter

line 687 cause endless loop in MaterialRippleLayout.java

code:
public RippleBuilder rippleInAdapter(boolean inAdapter) {
this.rippleInAdapter(inAdapter); //687
return this;
}

this.rippleInAdapter(inAdapter); maybe this.rippleSearchAdapter=inAdapter;

TabWidget ripple

I'd like to be able to add the ripple effect on a TabWidget

        View tab = tabs.getTabWidget().getChildTabViewAt(position);
        MaterialRippleLayout.on(tab)
                .rippleColor(Color.WHITE)
                .rippleOverlay(false)
                .rippleBackground(Color.BLUE)
                .create();

Getting Error in Android 2.0 to Android 3.0

02-06 01:46:59.563 678-678/com.androidbuts.sschsc E/AndroidRuntime﹕ FATAL EXCEPTION: main android.view.InflateException: Binary XML file line #7: Error inflating class com.balysv.materialripple.MaterialRippleLayout at android.view.LayoutInflater.createView(LayoutInflater.java:518) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570) at android.view.LayoutInflater.rInflate(LayoutInflater.java:623) at android.view.LayoutInflater.inflate(LayoutInflater.java:408) at android.view.LayoutInflater.inflate(LayoutInflater.java:320) at android.view.LayoutInflater.inflate(LayoutInflater.java:276) at com.androidbuts.sschsc.MenuActivity$MenuAdapter.getView(MenuActivity.java:294) at android.widget.AbsListView.obtainView(AbsListView.java:1418) at android.widget.ListView.makeAndAddView(ListView.java:1745) at android.widget.ListView.fillDown(ListView.java:670) at android.widget.ListView.fillFromTop(ListView.java:727) at android.widget.ListView.layoutChildren(ListView.java:1598) at android.widget.AbsListView.onLayout(AbsListView.java:1248) at android.view.View.layout(View.java:7175) at android.widget.RelativeLayout.onLayout(RelativeLayout.java:912) at android.view.View.layout(View.java:7175) at android.widget.FrameLayout.onLayout(FrameLayout.java:338) at android.view.View.layout(View.java:7175) at android.support.v7.internal.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:502) at android.view.View.layout(View.java:7175) at android.widget.FrameLayout.onLayout(FrameLayout.java:338) at android.view.View.layout(View.java:7175) at android.widget.FrameLayout.onLayout(FrameLayout.java:338) at android.view.View.layout(View.java:7175) at android.view.ViewRoot.performTraversals(ViewRoot.java:1140) at android.view.ViewRoot.handleMessage(ViewRoot.java:1859) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:123) at android.app.ActivityThread.main(ActivityThread.java:3647) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.constructNative(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:415) at android.view.LayoutInflater.createView(LayoutInflater.java:505)             at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)             at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)             at android.view.LayoutInflater.inflate(LayoutInflater.java:408)             at android.view.LayoutInflater.inflate(LayoutInflater.java:320)             at android.view.LayoutInflater.inflate(LayoutInflater.java:276)             at com.androidbuts.sschsc.MenuActivity$MenuAdapter.getView(MenuActivity.java:294)             at android.widget.AbsListView.obtainView(AbsListView.java:1418)             at android.widget.ListView.makeAndAddView(ListView.java:1745)             at android.widget.ListView.fillDown(ListView.java:670)             at android.widget.ListView.fillFromTop(ListView.java:727)             at android.widget.ListView.layoutChildren(ListView.java:1598)             at android.widget.AbsListView.onLayout(AbsListView.java:1248)             at android.view.View.layout(View.java:7175)             at android.widget.RelativeLayout.onLayout(RelativeLayout.java:912)             at android.view.View.layout(View.java:7175)             at android.widget.FrameLayout.onLayout(FrameLayout.java:338)             at android.view.View.layout(View.java:7175)             at android.support.v7.internal.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:502)             at android.view.View.layout(View.java:7175)             at android.widget.FrameLayout.onLayout(FrameLayout.java:338)             at android.view.View.layout(View.java:7175)             at android.widget.FrameLayout.onLayout(FrameLayout.java:338)             at android.view.View.layout(View.java:7175)             at android.view.ViewRoot.performTraversals(ViewRoot.java:1140)             at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)             at android.os.Handler.dispatchMessage(Handler.java:99)             at android.os.Looper.loop(Looper.java:123)             at android.app.ActivityThread.main(ActivityThread.java:3647)             at java.lang.reflect.Method.invokeNative(Native Method)             at java.lang.reflect.Method.invoke(Method.java:507)             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)             at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NoClassDefFoundError: com.balysv.materialripple.MaterialRippleLayout$4 at com.balysv.materialripple.MaterialRippleLayout.<init>(MaterialRippleLayout.java:456) at com.balysv.materialripple.MaterialRippleLayout.<init>(MaterialRippleLayout.java:111)             at java.lang.reflect.Constructor.constructNative(Native Method)             at java.lang.reflect.Constructor.newInstance(Constructor.java:415)             at android.view.LayoutInflater.createView(LayoutInflater.java:505)             at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)             at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)             at android.view.LayoutInflater.inflate(LayoutInflater.java:408)             at android.view.LayoutInflater.inflate(LayoutInflater.java:320)             at android.view.LayoutInflater.inflate(LayoutInflater.java:276)             at com.androidbuts.sschsc.MenuActivity$MenuAdapter.getView(MenuActivity.java:294)             at android.widget.AbsListView.obtainView(AbsListView.java:1418)             at android.widget.ListView.makeAndAddView(ListView.java:1745)             at android.widget.ListView.fillDown(ListView.java:670)             at android.widget.ListView.fillFromTop(ListView.java:727)             at android.widget.ListView.layoutChildren(ListView.java:1598)             at android.widget.AbsListView.onLayout(AbsListView.java:1248)             at android.view.View.layout(View.java:7175)             at android.widget.RelativeLayout.onLayout(RelativeLayout.java:912)             at android.view.View.layout(View.java:7175)             at android.widget.FrameLayout.onLayout(FrameLayout.java:338)             at android.view.View.layout(View.java:7175)             at android.support.v7.internal.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:502)             at android.view.View.layout(View.java:7175)             at android.widget.FrameLayout.onLayout(FrameLayout.java:338)             at android.view.View.layout(View.java:7175)             at android.widget.FrameLayout.onLayout(FrameLayout.java:338)             at android.view.View.layout(View.java:7175)             at android.view.ViewRoot.performTraversals(ViewRoot.java:1140)             at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)             at android.os.Handler.dispatchMessage(Handler.java:99)             at android.os.Looper.loop(Looper.java:123)             at android.app.ActivityThread.main(ActivityThread.java:3647)             at java.lang.reflect.Method.invokeNative(Native Method)             at java.lang.reflect.Method.invoke(Method.java:507)             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)             at dalvik.system.NativeStart.main(Native Method)

programmatically added ripple has no effect

I'm using "1.0.6-SNAPSHOT" from sonatype, which works fine, from last october.
Than i switched to the release version 1.0.1 and the programmatically added MaterialRippleLayout has no effect, when I click on the item itself. Do you have any hints?

get AnimationEnd to perform Custom Action after that?

Is it possible to get the End of the Rippleanimation.
I want to make the RippleAnimation to fill the screen and when it is filled( animation ended) the activity should be closed or anotherone should start.

so an ripplelayout.onAnimationEnd with returntype of boolean or something similar would be great

Request: Ripple Effect with vanishing

Hi,
You library is awesome, but I have a request. You could add the vanish effect to your lib?
It should be another ripple effect after the first, and it removes the ripple effect color, showing the background.
You can find an example here at the bottom of the page

Thank you

Crash when apply ripple builder on view holder

I'm trying your library on my view holder but when I run the project the application crash, these happend when I scroll the listView.

The code is:

public class CategoryViewCell extends AbstractAdapter
{

public CategoryViewCell(List<HashMap<String, Object>> dataModel){
    super(dataModel);
}

@Override
public View getView(int position, View convertView, ViewGroup viewGroup){

    ViewHolder viewHolder;
    if(convertView == null)
    {
        viewHolder = new ViewHolder();
        convertView = ApplicationLoader.mainLayoutInflater.inflate(R.layout.lsta_pral_item, null);
        viewHolder.imageView = (ImageView)convertView.findViewById(R.id.lstaPralItem);
        convertView.setTag(viewHolder);
    }
    else
    {
        viewHolder = (ViewHolder) convertView.getTag();
    }

    HashMap<String, Object> information = dataModel.get(position);
    String imagen = information.get("imagen").toString();

    Bitmap bitmapFromFile = ImageLoaderService.getInstance().getBitmapFromFile(imagen);
    if (bitmapFromFile != null)
    {
        viewHolder.imageView.setImageBitmap(bitmapFromFile);
    }
    else
    {
        viewHolder.imageView.setImageResource(R.drawable.no_found_image);
    }

    MaterialRippleLayout.on(viewHolder.imageView).rippleColor(Color.RED).create();


    return convertView;
}

private static class ViewHolder
{
    ImageView imageView;
}

}

And the crash is:

java.lang.IllegalStateException: MaterialRippleLayout could not be created: parent of the view already is a MaterialRippleLayout
        at org.pademobile.widgets.MaterialRippleLayout$RippleBuilder.create(MaterialRippleLayout.java:701)
        at org.pademobile.bills.artifacts.CategoryViewCell.getView(CategoryViewCell.java:60)
        at android.widget.AbsListView.obtainView(AbsListView.java:2255)
        at android.widget.ListView.makeAndAddView(ListView.java:1790)
        at android.widget.ListView.fillDown(ListView.java:691)
        at android.widget.ListView.fillGap(ListView.java:655)
        at android.widget.AbsListView.trackMotionScroll(AbsListView.java:5143)
        at android.widget.AbsListView.scrollIfNeeded(AbsListView.java:3243)
        at android.widget.AbsListView.onTouchMove(AbsListView.java:3587)
        at android.widget.AbsListView.onTouchEvent(AbsListView.java:3431)
        at android.view.View.dispatchTouchEvent(View.java:7736)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2212)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1945)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2218)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2218)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2218)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2218)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2218)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2218)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2218)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2218)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2218)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
        at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2068)
        at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1515)
        at android.app.Activity.dispatchTouchEvent(Activity.java:2466)
        at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2016)
        at android.view.View.dispatchPointerEvent(View.java:7916)
        at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4023)
        at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3902)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3452)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3502)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3471)
        at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3578)
        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3479)
        at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3635)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3452)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3502)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3471)
        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3479)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3452)
        at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5657)
        at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5588)
        at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5559)
        at androi

Rounded corners

Maybe I'm missing something, but I can't find a way to have the ripple stop at rounded corners.

ripple not showing on onTouch event

Ripple not showing on onTouch event. Here's my xml and code.

XML

        <com.balysv.materialripple.MaterialRippleLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:paddingBottom="10dp"
            android:paddingTop="10dp"
            app:mrl_rippleDuration="200"
            android:id="@+id/mrlOne"
            app:mrl_rippleHover="true"
            app:mrl_rippleOverlay="true">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:padding="5dp"
                android:text="1"
                android:textColor="#FAFAFA"
                android:textSize="30sp" />
        </com.balysv.materialripple.MaterialRippleLayout>

Code

 MaterialRippleLayout one = (MaterialRippleLayout) rootView.findViewById(R.id.mrlOne);
 one.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            Toast.makeText(getActivity(), "Hi!", Toast.LENGTH_SHORT).show();
            return true;
        }
    });

Call ripple from code

Can i call ripple-effect programmatically?
Something like:

MaterialRippleLayout.on(view)
           .rippleColor(Color.BLACK)
           .create().call(xStart, yStart);

Could not find a parent AdapterView

I'm frequently getting exception below while using material-ripple, usually while resuming the app. Can you please check it out and let me know how to ignore such exception.

Thanks in advance.

E/AndroidRuntime(29863): java.lang.RuntimeException: Could not find a parent AdapterView
E/AndroidRuntime(29863):    at com.balysv.materialripple.MaterialRippleLayout.findParentAdapterView(MaterialRippleLayout.java:409)
E/AndroidRuntime(29863):    at com.balysv.materialripple.MaterialRippleLayout.adapterPositionChanged(MaterialRippleLayout.java:423)
E/AndroidRuntime(29863):    at com.balysv.materialripple.MaterialRippleLayout.draw(MaterialRippleLayout.java:474)
E/AndroidRuntime(29863):    at android.view.View.updateDisplayListIfDirty(View.java:14167)

use for circular widgets

Hi. Thanks for sharing your library, how to use that for circular widgets and use that for listview items?

thanks

Can not work with EditText.

I try to add the rippe effect on the EditText just like the Google Search, but the EditText just can not get focus.

Image in item of listview

Hello,

I'm using your library in all my app and it's working really fine =)
I still have an issue when using it with a listview. It seems that the ripple is applied below the image which is in my item.
When my img is a transparent img, I can see the ripple behind it.
Here is my xml :

 <com.balysv.materialripple.MaterialRippleLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_height="144dp"
        android:layout_width="match_parent"
        app:mrl_rippleInAdapter="true"
        app:mrl_rippleOverlay="true"
        >

    <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        <com.android.volley.toolbox.NetworkImageView
                android:id="@+id/img"
                android:scaleType="centerCrop"
                android:layout_width="match_parent"
                android:layout_centerInParent="true"
                android:layout_height="144dp"/>

        <TextViez
                android:id="@+id/title"
                android:text="test"
                android:layout_gravity="center"
                android:layout_centerInParent="true"
                android:gravity="center"
                android:layout_width="match_parent"
                android:layout_height="match_parent"/>
    </RelativeLayout>
</com.balysv.materialripple.MaterialRippleLayout>

By the way, when I'm doing a longClick, the "slow ripple" is well applied on the foreground of the view...

Thanks for your help =)

Tom

OnClickListener never called when DelayClick is true

Hi,
I'm starting to use your lib and I got this issue. By default, the DelayClick is true, but when I tap on the view the ripple works great, but the ClickListener of my view isn't triggered. When I set the Delay to false works fine.

I take a look in your lib code and I found an IF that test if delay is false to run the click on child view, but if the test is true I didn't found the code to run the click on child when the animation finish.

If it is a real bug and you don't have time to fix, I can try to fork and fix to you.

Thanks

Null pointer exception on scrolling listview

When i click on ripple view and then scroll it fast enough to exit from listview layout (while ripple animation is already running) it threw a null pointer exception.
This only happens if mrl_rippleDelayClick set to true.

 FATAL EXCEPTION: main

java.lang.NullPointerException
        at android.widget.AdapterView.getPositionForView(AdapterView.java:598)
        at com.balysv.materialripple.MaterialRippleLayout$PerformClickEvent.clickAdapterView(MaterialRippleLayout.java:653)
        at com.balysv.materialripple.MaterialRippleLayout$PerformClickEvent.run(MaterialRippleLayout.java:645)
        at com.balysv.materialripple.MaterialRippleLayout$3.onAnimationEnd(MaterialRippleLayout.java:336)
        at android.animation.AnimatorSet$AnimatorSetListener.onAnimationEnd(AnimatorSet.java:818)
        at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1056)
        at android.animation.ValueAnimator.access$400(ValueAnimator.java:50)
        at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:644)
        at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:660)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
        at android.view.Choreographer.doCallbacks(Choreographer.java:574)
        at android.view.Choreographer.doFrame(Choreographer.java:543)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
        at android.os.Handler.handleCallback(Handler.java:733)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:5021)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:827)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:643)
        at dalvik.system.NativeStart.main(Native Method)

EDIT: when i set mrl_rippleInAdapter to false and mrl_rippleDelayClick to true , problem simply solve even i use ripple in listview and adapter. i expected to see more problem when set mrl_rippleInAdapter to false since i'm using it inside adapter , can you please explain what mrl_rippleInAdapter exactly doing and what will happen if it set to false?

PreferenceFragment?

I was wondering if there was an easy way to use this with a PreferenceFragment/PreferenceScreen.

Rendering Problems in AndroidStudio Layout Preview

The following classes could not be instantiated:
- com.balysv.materialripple.MaterialRippleLayout (Open Class, Show Exception)
 Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE

Inside AndroidStudio.
Maybe add view.isInEditMode() support?

I also keep getting:

Exception Details 
java.lang.ClassNotFoundException: com.nineoldandroids.util.Property

It's just in layout preview from AndroidStudio.
App is running fine, though. It's just quite annoying since you can't see your layout anymore from the editor.

Or maybe anyone have any trick to "fix" this?

Avoid create a MaterialRippleLayout when the view parent already is one

Hi balysv, it's me again.

This is a suggestion. Check if view parent already is a MaterialRiplleLayout before create a new one, to prevent stackoverflow.
I got this error in an adapter that I create the ripple on my code. But, as an adapter reuse the view, my code insert an MaterialRippleLayout inside another and this cause stackoverflow.
I fix the issue in my code, but I suggest this fix on the create method.

Thanks

Mechanism to avoid duplicate clicks

Hi

I noticed if i double clicked very fast (click before the ripple effect is finished).... 2 onclick events will be fired and two of my fragments will be pushed

I appreciate it if you can add some ways to prevent another onclick while ripple effect is running.

Thanks

LongClick not firing when moving finger.

When the LongClick listener is set to the view on which the MaterialRippleLayout is statically applied the event fires only when you don't move your finger while holding. It is the only place from which it is possible to consume the event. It behaves like this even in the demo application.

How to pass the click on view beneath the MaterialRippleLayout

I have buttons beneath the ripple layout which needs to be clicked. But the ripple layout is consuming it .

Any ideas ?

For example , the parent here is waterContainer and I have a TextView beneath it (waterMinus).

When I apply

     MaterialRippleLayout.on(waterContainer)
                .rippleBackground(getResources().getColor(R.color.blue))
                .rippleColor(getResources().getColor(R.color.white))
                .rippleAlpha(0.2f)
                .rippleHover(true)
                .create();

the click is consumed by waterContainer.

<LinearLayout
        android:id="@+id/waterContainer"
        android:gravity="center"
        android:paddingLeft="8dp"
        android:paddingRight="8dp"
        android:weightSum="3"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        >

        <TextView
            android:id="@+id/waterMinus"
            android:gravity="center"
            android:textColor="@color/white_alpha"
            android:textSize="120sp"
            android:text="-"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"/>

</LinearLayout>

How to define attributes in styles.xml?

I want to create a style in styles.xml so that I dont have to add those attributes on every place. Can I do that in styles.xml? If yes, please give an example as well. thanks

Backport to older android versions

I noticed minSdk is set to 14, so some users like me which are forced to support older versions can't use your library.

As an enhancement, if you do not want to support older android versions, you can add a section in the readme.md explaining that you can use this library using the Jake Wharton's animation backport (http://nineoldandroids.com/) changing the imports from import android.animation.*; to: import com.nineoldandroids.animation.*; ,
import android.util.Property; to import com.nineoldandroids.util.Property; and calling function shouldDelayChildPressedState() only if you're using api greater than 14.

Thank and congrats for the great job!
David.

Ripple layout in adapter

Hello,

I have problem with mateerial-ripple. I used this layout in adapter. Adapter xml look like this:

<com.balysv.materialripple.MaterialRippleLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:paddingTop="1dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    app:mrl_rippleDelayClick="true"
    style="@style/RippleWhite" >

....<!-- other widget -->
<ImageButton
                android:id="@+id/following_user_btn"
                style="@style/ButtonStyle"
                android:layout_width="48dp"
                android:layout_height="28dp"
                android:layout_marginRight="0dp"
                android:background="@drawable/button_user_action_v2"
                android:src="@drawable/button_follow_user"/>

</com.balysv.materialripple.MaterialRippleLayout>

OnClick on ImageButton in getView dosen't work. I dont why.

can sometimes get stuck on a specific phase

Might be an emulator issue, but long clicking an item could stop the ripple animation at some point, which doesn't look nice. I've tested it on the ListView and the recyclerView parts of the demo

onItemClick is called after onItemLongClick in RecycleView

Hi,
I tried it in a RecycleView with setting app:rippleInAdapter="false",
When I long click on an item in the list, the listener correctly called but immediately after that touch (MotionEvent.ACTION_UP) the onItemClick method of OnItemClickListener get called! even if returning true in onItemLongClick method!

I've tested it with a normal FrameLayout and it hasn't any problem...

It happend when
MaterialRippleLayout.setOnClickListener() and
MaterialRippleLayout.setOnLongClickListener()

\<com.balysv.materialripple.MaterialRippleLayout>
     \<View/>
\</com.balysv.materialripple.MaterialRippleLayout>"

When
View.setOnClickListener() and
View.setOnLongClickListener()

\<com.balysv.materialripple.MaterialRippleLayout>
     \<View/>
\<com.balysv.materialripple.MaterialRippleLayout>

Its work ok.

Changing color causes Ripple lost

I have the following Ripple in my layout

<com.balysv.materialripple.MaterialRippleLayout
            android:id="@+id/ripple"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:mrl_rippleColor="@color/green"
            app:mrl_rippleAlpha="0.8"
            app:mrl_rippleDimension="1dp"
            app:mrl_rippleDuration="350"
            app:mrl_ripplePersistent="true" >

            ...

</com.balysv.materialripple.MaterialRippleLayout>

And everything works as expected. By the way I tried to change ripple's color programmatically with the following Java code:

ripple.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                         selected = !selected;
                         ripple.setRippleColor(!selected ? white : green);
                }
});

At the first tap on my view ripple effect works fine. From the second tap it does not work anymore. Color is changed but ripple effect is not performed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.