今日推荐WeatherView是一个Android库,可以帮助你做一个很酷的天气动画为您的应用程序。
这个图书馆是基于这个Leonids图书馆。


使用Android Studio / grandle

添加到项目的build.gradle里面 :

repositories {
maven { url = ‘https://jitpack.io’ }
}

dependencies {
compile ‘com.github.MatteoBattilana:WeatherView:1.1.0’
}

基本用法

默认情况下,WeatherView设置为SUN,不显示动画。 可以使用setWeather(weatherStatus)方法更改或初始化天气状态。
默认情况下停止动画,并且必须使用startAnimation()启动。 当动画播放并调用上一个方法时,动画停止,必须重新启动。 WeatherView需要minSDK 14。
您可以检查WeatherView演示库源代码。
例子:

public class MainActivity extends Activity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        WeatherView mWeatherView = (WeatherView) findViewById(R.id.weather);        //Optional        mWeatherView.setWeather(Constants.weatherStatus.RAIN)                    .setLifeTime(2000)                    .setFadeOutTime(1000)                    .setParticles(43)                    .setFPS(60)                    .setAngle(-5);                    .startAnimation();    }}

将WeatherView包含到activity_main.xml中

.matteobattilana.library.WeatherView        xmlns:app="http://schemas.android.com/apk/res-auto"        android:id="@+id/weater"        android:layout_width="match_parent"        android:layout_height="1dp"        app:angle="-3"        app:fadeOutTime="1000"        app:fps="40"        app:lifeTime="2200"        app:numParticles="55"        app:startingWeather="RAIN"/>

允许xml定制具有以下属性:

        app:angle="int"        app:fadeOutTime="int"        app:fps="int"        app:lifeTime="int"        app:numParticles="int"        app:startingWeather="{RAIN,SNOW,SUN}"        angle是单个粒子的角度,0是垂直于地面。 此值必须大于-180且小于180。        fps 必须大于7且小于100        lifeTime 是单个粒子的下降时间。 此后,粒子停止存在。 必须大于0。        fadeOutTime 在lifeTime期间,粒子开始淡出。 此淡出动画持续指定的持续时间。 必须大于0。        numParticles 颗粒数量一秒。 必须大于0。        startingWeather 您可以指定说明天气状态,但startAnimation()必须被调用。

基本用法和介绍就是这些.本来是有gif的上传不上来,略坑 讲究的看看吧各位看官.

喜欢的可以关注微信公众号,哪里每天都会推荐一篇开源项目Git项目地址在里欢迎订阅

更多相关文章

  1. Android三种常用动画分享
  2. Android三种动画详解
  3. Android动画效果生动有趣的通知NiftyNotification(Android(安卓)T
  4. Android(安卓)如何从屏幕底部向上滑出一个view
  5. android UI进阶之弹窗的使用(2)--实现通讯录的弹窗效果
  6. Android属性动画优化(更高效的使用属性动画)
  7. Android(安卓)SVG矢量资源的使用方法
  8. Android包(android.view.animation)的简介
  9. Android矢量动画-VectorDrawable

随机推荐

  1. Android(安卓)打开关闭闪光灯(手电筒)
  2. Android(安卓)使用系统摄像头拍相片与拍
  3. Android(安卓)SQLite Database
  4. android一种较为复杂的布局
  5. android 之 选择文件
  6. android xml本地数据弹窗多选
  7. Android(安卓)WebView加载https网页(亲测)
  8. Android之setResult的用法
  9. android(linux) 背光流程
  10. 【Android】Http请求