现在感染症状有哪些,深圳罗湖企业网站优化,个人养老保险怎么交费,wordpress开发cms系统编写界面来显示返回的数据
用户友好性#xff1a;通过界面设计和用户体验优化#xff0c;可以使天气信息更易读、易理解和易操作。有效的界面设计可以提高用户满意度并提供更好的交互体验。
增加城市名字的TextView TextViewandroid:idid/textViewCityName…编写界面来显示返回的数据
用户友好性通过界面设计和用户体验优化可以使天气信息更易读、易理解和易操作。有效的界面设计可以提高用户满意度并提供更好的交互体验。
增加城市名字的TextView TextViewandroid:idid/textViewCityNameandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:width200dpandroid:height50dpapp:layout_constraintTop_toBottomOfid/buttonSearchapp:layout_constraintStart_toStartOfparentapp:layout_constraintEnd_toEndOfparentandroid:textSize20spandroid:gravitycenter/android:idid/textViewCityName给 TextView 设置了一个唯一的标识符以便于在代码中对其进行引用。android:layout_widthwrap_content 和android:layout_heightwrap_content设置 TextView 的宽度和高度分别根据文本内容自动调整。android:width200dp 和android:height50dp指定 TextView 的宽度和高度为 200dp 和 50dp。app:layout_constraintTop_toBottomOfid/buttonSearch将 TextView 的顶部与 id 为 buttonSearch 的视图的底部对齐。app:layout_constraintStart_toStartOfparent 和 app:layout_constraintEnd_toEndOfparent将 TextView 的左侧与父容器的左侧对齐将 TextView 的右侧与父容器的右侧对齐。android:textSize20sp设置 TextView 的文本字体大小为 20sp。android:gravitycenter将文本内容在 TextView 中水平和垂直居中。
增加温度显示部分 TextViewandroid:idid/textViewTemperatureandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentapp:layout_constraintTop_toBottomOfid/textViewCityNameapp:layout_constraintStart_toStartOfparentapp:layout_constraintEnd_toEndOfparentandroid:textSize30spandroid:gravitycenter/TextViewandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentapp:layout_constraintTop_toTopOfid/textViewTemperatureapp:layout_constraintStart_toEndOfid/textViewTemperatureandroid:textstring/degreeandroid:textSize20spandroid:gravitycenter /TextViewandroid:idid/textViewMaxMinTemperatureandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentapp:layout_constraintTop_toBottomOfid/textViewTemperatureapp:layout_constraintStart_toStartOfparentapp:layout_constraintEnd_toEndOfparentandroid:textSize12spandroid:gravitycenter /增加天气内容 TextViewandroid:idid/textViewWeatherandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentapp:layout_constraintTop_toBottomOfid/textViewMaxMinTemperatureapp:layout_constraintStart_toStartOfparentapp:layout_constraintEnd_toEndOfparentandroid:textSize20spandroid:gravitycenter /编写逻辑填充数据 SuppressLint(SetTextI18n)Subscribe(threadMode ThreadMode.MAIN)fun onEvent(event: WeatherResponseEvent) {val weatherResponse event.weatherResponseval kelvins 273.15val cityName weatherResponse.nameval temperature weatherResponse.main?.temp?.minus(kelvins)val maxTemperature weatherResponse.main?.temp_max?.minus(kelvins)val minTemperature weatherResponse.main?.temp_min?.minus(kelvins)findViewByIdTextView(R.id.textViewCityName).text cityNamefindViewByIdTextView(R.id.textViewTemperature).text temperature?.toInt().toString()findViewByIdTextView(R.id.textViewMaxMinTemperature).text ${maxTemperature?.toInt()} / ${minTemperature?.toInt()}findViewByIdTextView(R.id.textViewWeather).text ${weatherResponse.weather.first().main} | ${weatherResponse.weather.first().description}}最后的效果