Android自定义控件之天气视图

1

Gradle

compile 'me.zhouzhuo.zzweatherview:zz-weather-view:1.0.0'

2

效果图如下:

Android自定义控件之天气视图

3

用法简介:

1)布局

drawable/scroll_bar_thumb.xml

<?xml
 version="1.0" encoding="utf-8"?><shape 
xmlns:android="http://schemas.android.com/apk/res/android"> 
<gradient android:startColor="#33999999" android:endColor="#80aaaaaa"
 android:angle="0"/> <corners android:radius="6dp" 
/></shape>
<me.zhouzhuo.zzweatherview.ZzWeatherView
 android:id="@+id/weather_view" android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:scrollbarThumbHorizontal="@drawable/scroll_bar_thumb" 
android:scrollbarTrackHorizontal="@drawable/scroll_bar_thumb" 
android:scrollbarSize="4dp" android:background="#333" > 
</me.zhouzhuo.zzweatherview.ZzWeatherView>

2)java

ZzWeatherView
 weatherView = (ZzWeatherView) findViewById(R.id.weather_view); //填充天气数据
 weatherView.setList(generateData()); //画折线 
weatherView.setLineType(ZzWeatherView.LINE_TYPE_DISCOUNT); 
//画曲线(不够圆滑希望有更好的建议联系我(Email:admin@zhouzhuo810.me)) 
//weatherView.setLineType(ZzWeatherView.LINE_TYPE_CURVE); //设置线宽 
weatherView.setLineWidth(6f); //点击某一列 
weatherView.setOnWeatherItemClickListener(new 
ZzWeatherView.OnWeatherItemClickListener() { @Override public void 
onItemClick(WeatherItemView itemView, int position, WeatherModel 
weatherModel) { Toast.makeText(MainActivity.this, position+"", 
Toast.LENGTH_SHORT).show(); } });
//数据源
 WeatherModel model = new WeatherModel(); model.setDate("12/07");//日期 
model.setWeek("昨天"); //星期 model.setDayWeather("大雪"); //白天天气 
model.setDayTemp(11); //白天温度 model.setNightTemp(5); //夜晚温度 
model.setNightWeather("晴"); //夜晚天气 model.setWindOrientation("西南风"); //风向
 model.setWindLevel("3级"); // model.setAirLevel(AirLevel.EXCELLENT); 
//空气质量
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值