<Android 应用 之路> 天气预报(四)

前言

第二次尝试完成天气预报应用,与上次不同的是,个人感觉这次的Ui不那么丑陋,整体的实用性和界面效果,用户体验相较上一次有所提升,但是还是有很多地方需要完善。
这次使用到的内容比较丰富,包括聚合数据Sdk,ButterKnife,Gson,fastjson,其实还想用一下volley的,但是聚合数据中已经有对网络请求的处理,就没有深究,顺带的看了下Material Design的内容,这么早出来的内容,现在才去了解,感觉要看的东西有很多,先在这里Marking一下,后面会继续学习对应的内容。

成果展示

这里写图片描述

开发过程中遇到的问题

  1. ButterKnife注入后,报空指针异常
    解决办法:
    设置–>搜索Annotation Processor,保证Enable Annotation Processing打上勾

  2. 圆角编译框的Shape

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">

    <solid android:color="#ffffff"/>

    <stroke
            android:width="2dip"
            android:color="#A0A0A0"/>

    <padding
            android:bottom="10dp"
            android:left="10dp"
            android:right="10dp"
            android:top="10dp"/>

    <corners android:radius="10dp"/>
</shape>

然后采用android:background=”@drawable/shape”使用

3.已经使用了shape文件作为background的View如何设置背景色

GradientDrawable myGrad = (GradientDrawable)XXXView.getBackground();
myGrad.setColor(getResources().getColor(R.color.choosecitysearchbackground));

原文地址:https://www.cnblogs.com/lanzhi/p/6467207.html