2016-11-13 130 views
0

我正在開發一個應用程序,在該應用程序中我想在我的recyclerview中添加漣漪效應。所以任何人都可以告訴我這樣做的代碼,並且有一種方法可以在前棒棒糖中實現。如果沒有,請建議我使用我的應用程序代碼,可以顯示棒棒糖和高級版本中的連鎖效應,以及棒棒糖前的任何簡單效果,以顯示項目已被點擊或點擊。 謝謝。棒棒糖的漣漪效應

回答

1

你可以使用this library這個你可以在pre-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> 
0

爲何會出現在預棒棒糖沒有漣漪?

很多讓RippleDrawable能夠流暢運行的是Android 5.0的 新的RenderThread。爲了優化Android的早期版本 的性能,我們現在已經將RippleDrawable離開了。

http://android-developers.blogspot.com.uy/2014/10/appcompat-v21-material-design-for-pre.html

如果你想預棒棒糖,你前人的精力用像庫:

https://github.com/balysv/material-ripple

https://github.com/traex/RippleEffect

其他庫:https://android-arsenal.com/tag/167

對於> = 21 API你只需要在你的佈局中設置:

android:background="?android:attr/selectableItemBackground"