前棒棒糖的涟漪效应
Ripple Effect for pre lollipop
我正在开发一个应用程序,我想在我的 recyclerview 中添加涟漪效果。那么谁能告诉我执行此操作的代码,有没有一种方法可以让我在 pre lollipop 中也能实现它。如果没有,请建议我使用我的应用程序编写的代码可以在棒棒糖和更高版本中显示波纹效果,以及棒棒糖之前的任何简单效果,以显示项目已被点击或点击。
谢谢。
你可以使用 this library 这样你也可以在 Lolipop 之前的版本上添加连锁反应。
例如
在布局文件中添加按钮
<com.rey.material.widget.Button
style="@style/ButtonRippleStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BUTTON"
app:rd_enable="true"/>
在样式文件中添加自定义样式
<style name="ButtonRippleStyle" parent="Material.Drawable.Ripple.Wave.Light">
<item name="android:background">@null</item>
<item name="rd_rippleColor">#20F15A2B</item>
</style>
Why are there no ripples on pre-Lollipop?
A lot of what allows RippleDrawable to run smoothly is Android 5.0’s
new RenderThread. To optimize for performance on previous versions of
Android, we've left RippleDrawable out for now.
http://android-developers.blogspot.com.uy/2014/10/appcompat-v21-material-design-for-pre.html
如果你想要 pre-lollipop,你应该使用像这样的库:
https://github.com/balysv/material-ripple
https://github.com/traex/RippleEffect
其他图书馆:https://android-arsenal.com/tag/167
For >= 21 API 你只需要在你的布局中设置:
android:background="?android:attr/selectableItemBackground"
我正在开发一个应用程序,我想在我的 recyclerview 中添加涟漪效果。那么谁能告诉我执行此操作的代码,有没有一种方法可以让我在 pre lollipop 中也能实现它。如果没有,请建议我使用我的应用程序编写的代码可以在棒棒糖和更高版本中显示波纹效果,以及棒棒糖之前的任何简单效果,以显示项目已被点击或点击。 谢谢。
你可以使用 this library 这样你也可以在 Lolipop 之前的版本上添加连锁反应。
例如
在布局文件中添加按钮
<com.rey.material.widget.Button
style="@style/ButtonRippleStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BUTTON"
app:rd_enable="true"/>
在样式文件中添加自定义样式
<style name="ButtonRippleStyle" parent="Material.Drawable.Ripple.Wave.Light">
<item name="android:background">@null</item>
<item name="rd_rippleColor">#20F15A2B</item>
</style>
Why are there no ripples on pre-Lollipop?
A lot of what allows RippleDrawable to run smoothly is Android 5.0’s new RenderThread. To optimize for performance on previous versions of Android, we've left RippleDrawable out for now.
http://android-developers.blogspot.com.uy/2014/10/appcompat-v21-material-design-for-pre.html
如果你想要 pre-lollipop,你应该使用像这样的库:
https://github.com/balysv/material-ripple
https://github.com/traex/RippleEffect
其他图书馆:https://android-arsenal.com/tag/167
For >= 21 API 你只需要在你的布局中设置:
android:background="?android:attr/selectableItemBackground"