看了一个开源项目 https://github.com/daimajia/AndroidViewHoverhtml
主要就是利用这个库作一些动画效果java
import android.support.v8.renderscript.Allocation;android
import android.support.v8.renderscript.Element;import android.support.v8.renderscript.RenderScript;git
import android.support.v8.renderscript.ScriptIntrinsicBlur;github
默认eclipse没办法直接找到这个renderscript这个类库,须要你到支持这个jar包的目录在\sdk\build-tools\里面app
直接copy到你的project的libs目录下便可。eclipse
后记:动画
或许有的朋友会遇到如下错误ui
10-05 23:39:51.000: E/AndroidRuntime(4160): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.daimajia.androidviewhover.demo/com.daimajia.androidviewhover.demo.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
this
这个错误信息提示比较清楚了,须要在value目录里的style.xml写成如下:
<resources> <!-- Base application theme. --> <style name="AppTheme" parent="@style/Theme.AppCompat"> <!-- Customize your theme here. --> </style> </resources>