当前位置:网站首页>When the interviewer opens his mouth, he comes to compose. Is this the case now?

When the interviewer opens his mouth, he comes to compose. Is this the case now?

2022-06-11 02:34:00 Programmer Yidong

Preface

stay Android in ,UI The history of the toolkit can be traced back to at least 10 Years ago , Since then , Things have changed a lot , For example, the equipment we use , User expectations , And what developers are using for them Development tools and language expectations .Google in the light of Many adjustments have been made to different problems , however Only in UI In terms of construction , The first set UI The construction system has been used up to now , Almost no adjustments have been made .

However, in 2019 Year of google I/O At the conference ,Jetpack For the first time, the team introduced Jetpack Compose, This is a kind of all-new Android UI Component library .

Google Why build Compose

Jetpack Compose yes Google from 17 Year to 21 year ** It took five years to build , Used to build Android Native interface new UI tool kit .**Android It was born many years ago ,UI The system is already mature , Why rebuild a wheel like this ?

as everyone knows ,Android Traditional imperative UI The development has the following problems

  • XML Lengthy layout 、 tedious : Encountered complex layout , You can't see the whole screen vertically

  • View The nesting of programming methods has a performance impact : Unreasonable layout results in double measurement performance

  • Manually updating the view is complicated 、 Fallible

  • Declarative interface models are becoming increasingly popular : This way can simplify UI Build and update steps for , Only make the necessary changes

But it is born by following the trend Compose It not only solves these problems but also has more advantages

  • declarative UI: Only responsible for describing the interface ,Compose The system is responsible for the rest of the work

  • State driven : The interface is automatically updated with the status

  • Efficient rendering : Fixed measurement , Hierarchical nesting performance is still O(n)

  • combination AS Of Preview The view can be viewed in real time and interacted directly UI

  • Compatible with tradition View Tree programming , Can be mixed

  • Have Jetpack The strong cooperation of the framework

  • be based on Kotlin, The code is concise , A lot of Kotlin exclusive API

Jetpack Compose Is it necessary to learn ?

** declarative UI The eldest brother Flutter ** It's been a long time , To learn Compose Is there any point ,Flutter still Compose My answer is : If you will continue to Android platform ,Compose You have to be able to

First Compose yes Jetpack The new of the series UI library ,Compose yes Jetpack One of the members of the series , So it can be applied to Android Interface development , but **Compose yes Android UI The future of ,** At this stage, you can not , Certainly not in the future !

Compose Purpose of birth : Just to redefine Android On UI The way of writing , in order to Improve Android Native UI Development efficiency , Give Way Android Of UI The development method can keep up with the pace of the times .

How to play Jetpack Compose

compose As a new UI frame , so to speak Rendering 、 Layout 、 Touch algorithm and UI How to write it It's all new ! However, from 1.0 There are no comprehensive resources on the market after the release of the version , There are some difficulties in learning

In order to make everyone efficient , Fast , Overall learning Compose, Xiaobian has collected and sorted out GitHub Open source project Jetpack compose Project practice manual , Let's share it with you today . Let you stand in the perspective of Google engineers , Depth of understanding Compose The bottom layer and how to solve the actual project !

Chapter one First time to know Jetpack Compose

Why do we need a new UI Tools ?
Jetpack Compose Focus on

  • Accelerate development
  • Powerful UI Tools
  • Intuitive Kotlin API

  • API Design

Compose API Principles

  • Everything is a function
  • Top level function (Top-level function)
  • Combination over inheritance
  • Trust a single source

Deepen understanding Compose

  • Core
  • Foundation
  • Material

Chapter two Jetpack Compose structure Android UI

Android Jetpack Compose The best guide to getting started

  • Jetpack Compose Environmental preparation and Hello World
  • Layout
  • Use Material design Design
  • Compose Real time preview of the layout
  • ……

Go into detail Jetpack Compose | Optimize UI structure

  • Compose The problem solved
  • Composable Function analysis
  • declarative UI
  • Combine vs Inherit
  • encapsulation
  • restructuring
  • ……

  • Go into detail Jetpack Compose | Realization principle
  • @Composable What does annotation mean ?
  • Execution mode
  • Positional Memoization ( Place memory )
  • Store parameters
  • restructuring
  • ……

The third chapter Jetpack Compose Project practice ( attach Demo)

Jetpack Compose application 1

  • Preparation before start
  • establish DEMO
  • Problems encountered

Jetpack Compose application 2

  • Jetpack Compose The application makes a countdown timer
  • data structure
  • Countdown function
  • The state pattern
  • Compose Layout
  • Draw the clock

use Jetpack Compose Write a play Android App

  • preparation
  • Introduce dependencies
  • newly build Activity
  • establish Compose
  • PlayTheme
  • Draw page
  • Bottom navigation bar
  • Management status
  • Add a page

use Compose Android Write a weather app

  • The opening
  • Draw page
  • Painting background
  • Painting content
  • ……

use Compose Quickly build a “ The movie App

  • finished product
  • Implementation scheme
  • actual combat
  • Insufficient
  • ……

For reasons of length , This pure handwritten note has been organized into PDF file , You need this 《Android Jetpack compose Project practice manual 》 The complete document can be scanned below CSDN Official authentication QR code is enough 100% Free access !

原网站

版权声明
本文为[Programmer Yidong]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203020609368473.html