# RippleDrawable **Repository Path**: studvc/RippleDrawable ## Basic Information - **Project Name**: RippleDrawable - **Description**: Ripple effect for Android 14+ - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-01-05 - **Last Updated**: 2021-01-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README *RippleDrawable* ============= Port of Android `` effect for pre lollipop devices with android 14 + (ICS+) (well, since NineOldAndroids is deprecated, this library become 14 + only) ### Features 1. XML inflating 2. Ripple supports different shapes 3. Custom drawable loader 4. Define your custom drawable tags #### Implementation Create your desirable ripple.xml in `drawable/` folder ```xml ``` Secondly we need to inflate `RippleDrawable` and intercept `View` touches see `LollipopDrawablesCompat` and `DrawableHotspotTouch` for inflating and interception sequently. Here is sample: ```java public class SampleActivity extends AppCompatActivity { private FloatingActionButton mActionButton; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sample); mActionButton = (FloatingActionButton) findViewById(R.id.fab); mActionButton.setBackgroundDrawable(getDrawable2(R.drawable.fab_background)); mActionButton.setClickable(true);// if we don't set it true, ripple will not be played mActionButton.setOnTouchListener( new DrawableHotspotTouch((LollipopDrawable) mActionButton.getBackground())); } /** * {@link #getDrawable(int)} is already taken by Android API * and method is final, so we need to give another name :( */ public Drawable getDrawable2(int id){ return LollipopDrawablesCompat.getDrawable(getResources(), id, getTheme()); } } ``` **Thats it!** ##Dependency root build.gradle add a repository ```groovy repositories { maven { url "https://jitpack.io" } } ``` and in application module just add ```groovy dependencies { compile 'com.github.ozodrukh:RippleDrawable:2.0.0' } ``` #### a little bit more you can inflate and create your own `Drawable`classes, here is tips & tricks 1 extend your Drawable from `LollipopDrawable` ```java public class LayerDrawable extends LollipopDrawable { ``` 2 implement your own inflation ```java public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs, Resources.Theme theme); ``` 3 Register your `LollipopDrawable` ```java static { LollipopDrawablesCompat.registerDrawable(RippleDrawable.class, "ripple"); } ``` 4 inflate it! ```java LollipopDrawablesCompat.getDrawable(getResources(), R.drawable.custom_drawable, getTheme()); ``` License -------- The MIT License (MIT) Copyright (c) 2015 Abdullaev Ozodrukh Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.