仿小米MIUI8天气24小时预报折线图控件
源码解析博客地址
http://blog.csdn.net/ccy0122/article/details/76464825
xml:
<com.example.ccy.miuiweatherline.MiuiWeatherView
android:id="@+id/weather"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:line_interval="60dp" (可选,相邻点距离)
app:min_point_height="60dp" (可选,折线最低高度)
app:background_color="#ffffff"/> (可选,背景色)
code:
使用com.example.ccy.miuiweatherline.WeatherBean
作为元数据:
weatherView = (MiuiWeatherView) findViewById(R.id.weather);
List<WeatherBean> data = new ArrayList<>();
//add your WeatherBean to data
WeatherBean b1 = new WeatherBean(WeatherBean.SUN,20,"05:00");
WeatherBean b2 = new WeatherBean(WeatherBean.RAIN,22,"日出","05:30");
//b3、b4...bn
data.add(b1);
data.add(b2);
weatherView.setData(data);
(代码很少,建议直接copy,因为大家应该大概率会去修改/增加源码的天气icon、天气类型等)