百度面试官网,Android MVVM框架搭建,Android工作经验6年

public void setDistrict(String district) {

this.district = district;

}

public LocalWeatherLive getLocalWeatherLive() {

return localWeatherLive;

}

public void setLocalWeatherLive(LocalWeatherLive localWeatherLive) {

this.localWeatherLive = localWeatherLive;

}

}

这个数据将会绑定到我们的天气弹窗,现在来创建这个弹窗的布局。

② 天气弹窗布局

弹窗布局分为两个环节,一个是实时天气,一个是预报天气。首先colors.xml创建一个颜色值,如下:

#90000000

然后在drawable下创建一个shape_translucent_radius_12.xml样式文件,代码如下:

<?xml version="1.0" encoding="utf-8"?>

下面创建弹窗的布局,在layout下新建一个dialog_weather.xml,里面的代码如下:

<?xml version="1.0" encoding="utf-8"?>

<variable

name=“liveWeather”

type=“com.llw.mvvm.model.LiveWeather” />

<RelativeLayout

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:background=“#00000000”

android:orientation=“vertical”

android:paddingStart=“12dp”

android:paddingEnd=“12dp”

android:paddingBottom=“?attr/actionBarSize”>

<TextView

android:id=“@+id/tv_city”

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:layout_marginBottom=“12dp”

android:background=“@drawable/shape_translucent_radius_12”

android:gravity=“center”

android:padding=“12dp”

android:text=“@{liveWeather.district}”

android:textColor=“@color/white”

android:textSize=“28sp” />

<TextView

android:id=“@+id/tv_weather”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_above=“@+id/tv_report_time”

android:layout_below=“@+id/tv_city”

android:layout_alignParentStart=“true”

android:layout_marginEnd=“12dp”

android:layout_marginBottom=“12dp”

android:background=“@drawable/shape_translucent_radius_12”

android:gravity=“center”

android:padding=“12dp”

android:text=“@{liveWeather.localWeatherLive.weather}”

android:textColor=“@color/white”

android:textSize=“24sp” />

<LinearLayout

android:id=“@+id/wind_lay”

android:layout_width=“wrap_content”

android:layout_height=“44dp”

android:layout_below=“@+id/tv_city”

android:layout_toStartOf=“@+id/tv_temp”

android:layout_toEndOf=“@+id/tv_weather”

android:background=“@drawable/shape_translucent_radius_12”

android:gravity=“center”

android:orientation=“horizontal”>

<TextView

android:id=“@+id/tv_wind_direction”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_marginEnd=“12dp”

android:text=“@{liveWeather.localWeatherLive.windDirection+}”

android:textColor=“@color/white” />

<TextView

android:id=“@+id/tv_wind_power”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_marginStart=“12dp”

android:text=“@{liveWeather.localWeatherLive.windPower+}”

android:textColor=“@color/white” />

<LinearLayout

android:id=“@+id/humidity_lay”

android:layout_width=“wrap_content”

android:layout_height=“44dp”

android:layout_below=“@+id/wind_lay”

android:layout_marginTop=“12dp”

android:layout_toStartOf=“@+id/tv_temp”

android:layout_toEndOf=“@+id/tv_weather”

android:background=“@drawable/shape_translucent_radius_12”

android:gravity=“center”

android:orientation=“horizontal”>

<TextView

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_marginEnd=“24dp”

android:text=“湿度”

android:textColor=“@color/white” />

<TextView

android:id=“@+id/tv_humidity”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:text=“@{liveWeather.localWeatherLive.humidity+%}”

android:textColor=“@color/white” />

<TextView

android:id=“@+id/tv_temp”

android:layout_width=“100dp”

android:layout_height=“100dp”

android:layout_below=“@+id/tv_city”

android:layout_alignParentEnd=“true”

android:layout_marginStart=“12dp”

android:layout_marginBottom=“12dp”

android:background=“@drawable/shape_translucent_radius_12”

android:gravity=“center”

android:padding=“12dp”

android:text=“@{liveWeather.localWeatherLive.temperature+}”

android:textColor=“@color/white”

android:textSize=“32sp” />

<TextView

android:id=“@+id/tv_report_time”

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:layout_below=“@+id/tv_temp”

android:background=“@drawable/shape_translucent_radius_12”

android:gravity=“center”

android:padding=“12dp”

android:text=“@{liveWeather.localWeatherLive.reportTime+发布}”

android:textColor=“@color/white” />

<androidx.recyclerview.widget.RecyclerView

android:id=“@+id/rv_forecast”

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:layout_below=“@+id/tv_report_time”

android:layout_marginTop=“12dp” />

有列表就有对应的item布局,在layout下创建item_forecast.xml布局,代码如下:

<?xml version="1.0" encoding="utf-8"?>

<variable

name=“forecast”

type=“com.amap.api.services.weather.LocalDayWeatherForecast” />

<RelativeLayout

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:layout_marginBottom=“12dp”

android:background=“@drawable/shape_translucent_radius_12”

android:padding=“12dp”>

<TextView

android:id=“@+id/tv_date”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:text=“@{forecast.date}”

android:textColor=“@color/white” />

<TextView

android:id=“@+id/tv_week”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_marginStart=“12dp”

android:layout_toEndOf=“@+id/tv_date”

android:text=“@{EasyDate.getWeek(forecast.date)}”

android:textColor=“@color/white” />

<TextView

android:id=“@+id/tv_temp”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_alignParentEnd=“true”

android:text=“@{forecast.dayTemp+° /+ forecast.nightTemp+°}”

android:textColor=“@color/white” />

这里我引入的数据源是高德的,同时我还插入了一个工具类,这个工具类用于对日期进行处理,可以直接在xml中调用,例如将2021-12-22,转换成星期三。

布局都写好了,下面在themes.xml中增加一个样式,代码如下:

这表示底部弹窗出现是不会使我们的屏幕变暗。

③ BottomSheetDialog使用

在写之前,我们先写一个ForecastAdapter,这是天气预报的列表适配器,在adapter包下创建它,代码如下:

public class ForecastAdapter extends BaseQuickAdapter<LocalDayWeatherForecast, BaseDataBindingHolder> {

public ForecastAdapter(@Nullable List data) {

super(R.layout.item_forecast, data);

}

@Override

protected void convert(@NotNull BaseDataBindingHolder bindingHolder, LocalDayWeatherForecast localDayWeatherForecast) {

ItemForecastBinding binding = bindingHolder.getDataBinding();

if (binding != null) {

binding.setForecast(localDayWeatherForecast);

binding.executePendingBindings();

}

}

}

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数Android工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Android移动开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
img
img
img
img
img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Android开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新

如果你觉得这些内容对你有帮助,可以添加V获取:vip204888 (备注Android)
img

一个人可以走的很快,但一群人才能走的更远。如果你从事以下工作或对以下感兴趣,欢迎戳这里加入程序员的圈子,让我们一起学习成长!

AI人工智能、Android移动开发、AIGC大模型、C C#、Go语言、Java、Linux运维、云计算、MySQL、PMP、网络安全、Python爬虫、UE5、UI设计、Unity3D、Web前端开发、产品经理、车载开发、大数据、鸿蒙、计算机网络、嵌入式物联网、软件测试、数据结构与算法、音视频开发、Flutter、IOS开发、PHP开发、.NET、安卓逆向、云计算

零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Android开发知识点,真正体系化!**

由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新

如果你觉得这些内容对你有帮助,可以添加V获取:vip204888 (备注Android)
[外链图片转存中…(img-ybru42m3-1712325097314)]

一个人可以走的很快,但一群人才能走的更远。如果你从事以下工作或对以下感兴趣,欢迎戳这里加入程序员的圈子,让我们一起学习成长!

AI人工智能、Android移动开发、AIGC大模型、C C#、Go语言、Java、Linux运维、云计算、MySQL、PMP、网络安全、Python爬虫、UE5、UI设计、Unity3D、Web前端开发、产品经理、车载开发、大数据、鸿蒙、计算机网络、嵌入式物联网、软件测试、数据结构与算法、音视频开发、Flutter、IOS开发、PHP开发、.NET、安卓逆向、云计算

  • 12
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值