Android 很酷的天气动画控件

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u012162503/article/details/53518549

今日推荐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中

<xyz.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项目地址在里欢迎订阅
这里写图片描述

猜你喜欢

转载自blog.csdn.net/u012162503/article/details/53518549