GithubHelp home page GithubHelp logo

likaiyuan559 / toucheffects Goto Github PK

View Code? Open in Web Editor NEW
206.0 4.0 21.0 2.82 MB

Android View点击特效TouchEffects,几行代码为所有控件添加点击效果

License: MIT License

Java 100.00%
android view touch click effects

toucheffects's Introduction

Android 点击特效TouchEffects

TouchEffects能够帮助你更快速方便的增加点击时候的效果,TouchEffects的目标是打造一个稳定、全面、且能更方便的自定义及个性化的一款点击效果框架。

功能特点:

  • 只需要几行代码便能为全局的View加上点击效果

  • 支持多种点击效果

  • 支持个性化设置

  • 支持View的独立效果

效果支持:

  • Scale(点击缩放)

  • Ripple(点击水波纹)

  • Ripple_1(点击水波纹1)

  • State(点击渐变)

  • Shake(触碰抖动,用于不可点击时的反馈)

  • 更多效果敬请期待

文档

效果演示

缩放效果 水波纹效果
渐变效果 水波纹1设置
抖动效果 个性化设置

简单用例

1.设置maven仓库

allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }

2.添加依赖

普通版本

目前已经全面转为androidx,普通版本将不再维护,请各位尽快使用androidx哦

implementation 'com.github.likaiyuan559:TouchEffects:v0.1.3'

androidx

implementation 'com.github.likaiyuan559:TouchEffects:0.4.1'

初始化设置

1.设置全局属性

public class MyApplication extends Application {

    static {
        TouchEffectsManager.build(TouchEffectsWholeType.SCALE)//设置全局使用哪种效果
                .addViewType(TouchEffectsViewType.ALL)//添加哪些View支持这个效果
                .setListWholeType(TouchEffectsWholeType.RIPPLE);//为父控件为列表的情况下,设置特定效果
                                .setAspectRatioType(4f,TouchEffectsWholeType.RIPPLE);//宽高比大于4时启动水波纹
    }
    ...

}

在BaseActivity中添加代码

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {

    TouchEffectsFactory.initTouchEffects(this);

    super.onCreate(savedInstanceState);

}

给View设置点击事件

view.setOnClickListener(this);

控件支持

  • TextView

  • Button

  • ImageView

  • ImageButton

  • FrameLayout

  • LinearLayout

  • RelativeLayout

  • ConstraintLayout

  • 增加支持AppCompat系列

问题反馈

因个人精力问题,项目已不再维护,各位开发者可以根据自己需求作为参考,但不建议再直接使用了。

喜欢请给个Star

toucheffects's People

Contributors

likaiyuan559 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

toucheffects's Issues

ClassCastException

带有webview的界面中使用,webview加载完成后出现如下错误:
09-05 21:03:06.917 3779-3872/com.xujl.mvcbind W/art: Method processed more than once: java.lang.String org.chromium.net.X509Util.hashPrincipal(javax.security.auth.x500.X500Principal)
09-05 21:03:07.289 3779-3779/com.xujl.mvcbind W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 3779
09-05 21:03:08.689 3779-3779/com.xujl.mvcbind W/art: Method processed more than once: java.util.Map com.android.webview.chromium.WebViewUrlWatcher.readConfigFile()
09-05 21:03:08.933 3779-3779/com.xujl.mvcbind W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 3779
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: android.view.InflateException: Binary XML file line #95: com.lky.toucheffectsmodule.effects_view.TouchEffectsButton cannot be cast to android.view.ViewGroup
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at androidx.appcompat.app.AppCompatDialog.setContentView(AppCompatDialog.java:94)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at androidx.appcompat.app.AlertController.installContent(AlertController.java:232)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at androidx.appcompat.app.AlertDialog.onCreate(AlertDialog.java:279)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at android.app.Dialog.dispatchOnCreate(Dialog.java:394)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at android.app.Dialog.show(Dialog.java:295)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at com.just.agentweb.DefaultUIController.onOpenPagePrompt(DefaultUIController.java:83)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at com.just.agentweb.AgentWebUIControllerImplBase.onOpenPagePrompt(AgentWebUIControllerImplBase.java:44)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at com.just.agentweb.DefaultWebClient.deepLink(DefaultWebClient.java:258)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at com.just.agentweb.DefaultWebClient.shouldOverrideUrlLoading(DefaultWebClient.java:301)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at com.just.agentweb.WebViewClientDelegate.shouldOverrideUrlLoading(WebViewClientDelegate.java:58)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at com.android.webview.chromium.WebViewContentsClientAdapter.shouldOverrideUrlLoading(WebViewContentsClientAdapter.java:342)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at org.chromium.android_webview.AwContentsClient.shouldIgnoreNavigation(AwContentsClient.java:168)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at org.chromium.android_webview.AwContentsClientBridge.shouldOverrideUrlLoading(AwContentsClientBridge.java:256)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:39)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at android.os.Looper.loop(Looper.java:148)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5539)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at java.lang.reflect.Method.invoke(Native Method)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:745)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:635)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: Caused by: java.lang.ClassCastException: com.lky.toucheffectsmodule.effects_view.TouchEffectsButton cannot be cast to android.view.ViewGroup
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at android.view.LayoutInflater.rInflate(LayoutInflater.java:836)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at android.view.LayoutInflater.parseInclude(LayoutInflater.java:971)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at android.view.LayoutInflater.rInflate(LayoutInflater.java:831)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
09-05 21:03:09.060 3779-3779/com.xujl.mvcbind W/System.err: ... 24 more

TouchEffects造成RecyclerView点击错误

fragment中添加了7个item,点击低4个弹出activity后返回 ,然后点击第二个,发现点击第二个item获取到的信息还是刚才点击的第4个item的信息.去掉Toucheffects就不会有这个问题了.

部分不起作用

目前发现个问题,正常在layout布局里静态添加到xml的控件正常 ,但动态创建后 通过FrameLayout add 到 这样的view 不起作用

不能适配圆角的情况

设置ripple的情况下,带圆角的view点击效果指示的还是不带圆角的view,影响点击体验

dialog报错

android.view.InflateException: Binary XML file line #97: com.lky.toucheffectsmodule.effects_view.TouchEffectsButton cannot be cast to android.view.ViewGroup

直接闪退,类型转换异常

使用 androidx.appcompat.widget.AppCompatRadioButton 会报类型转换异常
java.lang.ClassCastException: com.lky.toucheffectsmodule.effects_view.TouchEffectsButton cannot be cast to androidx.appcompat.widget.AppCompatRadioButton

建议收集

有任何建议都可以在这里提出,作者会认真阅读。

自定义AlertDialog 的View时候报错

2017-08-06 04:24:36.976 11296-11296/com.deling.launcher E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.deling.launcher, PID: 11296
android.view.InflateException: Binary XML file line #95: com.lky.toucheffectsmodule.effects_view.TouchEffectsButton cannot be cast to android.view.ViewGroup
Caused by: java.lang.ClassCastException: com.lky.toucheffectsmodule.effects_view.TouchEffectsButton cannot be cast to android.view.ViewGroup
at android.view.LayoutInflater.rInflate(LayoutInflater.java:864)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:995)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:859)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatDialog.setContentView(AppCompatDialog.java:95)
at androidx.appcompat.app.AlertController.installContent(AlertController.java:232)
at androidx.appcompat.app.AlertDialog.onCreate(AlertDialog.java:279)
at android.app.Dialog.dispatchOnCreate(Dialog.java:403)
at android.app.Dialog.show(Dialog.java:302)
at com.hrs.setting.fragments.syssetting.wifi2.CustomDialogManager.createDialog(CustomDialogManager.java:59)
at com.hrs.setting.fragments.syssetting.wifi2.WifiContentDialog.createDetailDialog(WifiContentDialog.java:86)
at com.hrs.setting.fragments.syssetting.wifi2.SettingNet_wifiFragment.showWifiDetailDialog(SettingNet_wifiFragment.java:385)
at com.hrs.setting.fragments.syssetting.wifi2.SettingNet_wifiFragment.onItemClick2(SettingNet_wifiFragment.java:633)
at com.hrs.setting.fragments.syssetting.wifi2.SettingNet_wifiFragment$2.onItemClicked(SettingNet_wifiFragment.java:236)
at com.hrs.setting.adapter.WifiDisListAdapter$ViewHolder$1.onClick(WifiDisListAdapter.java:144)
at com.lky.toucheffectsmodule.effects_adapter.EffectsAdapter.lambda$createClick$0(EffectsAdapter.java:115)
at com.lky.toucheffectsmodule.effects_adapter.-$$Lambda$EffectsAdapter$Yq9_SbqlNb8wh814PtBEwLQABQY.run(Unknown Source:4)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

列表滑动时可不可以不触发点击效果?

在普通的veiw或者RecyclerView中,如果执行滑动的手势,会触发点击效果。普通的view还好,但是RecyclerView触碰的item会闪烁一下,用户体验不是很好。这个有没有办法处理呢?我看了看微信,微信在滑动列表时item是没有反馈的,似乎是加了个延迟来判断的点击还是滑动。

启动报错!!!java.lang.NoSuchMethodError: No static method metafactory

java.lang.NoSuchMethodError: No static method metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; in class Ljava/lang/invoke/LambdaMetafactory; or its super classes (declaration of 'java.lang.invoke.LambdaMetafactory' appears in /apex/com.android.runtime/javalib/core-oj.jar)

重大bug,重大bug,重大bug

我的华为手机有时候点了一会儿之后,再次点击所有的按钮都无效了,点击没有反应。

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.