当前位置: 首页 > 软件库 > 手机/移动开发 > >

Learn-Jetpack-Compose-By-Example

授权协议 Apache-2.0 License
开发语言 Kotlin
所属分类 手机/移动开发
软件类型 开源软件
地区 不详
投 递 者 巢安澜
操作系统 Android
开源组织
适用人群 未知
 软件概览

Learn Jetpack Compose By Example

Android CI

Over the course of the last few years Android development has gonethrough significant changes in how we structure our apps, the languagewe use for development, the tooling & libraries that help us speed upour development and the improvements in testing our apps. What had notchanged in all these years is the Android UI toolkit. This changes withJetpack Compose that aims to re-imagine what Android UI developmentwould look like using declarative programming principles. It is heavilyinfluenced by existing web and mobile frameworks such as React, Litho,Vue & Flutter and would be a paradigm shift in Android UI development aswe know it.

This repository aims to show the Jetpack Compose way of building commonAndroid UI that we are accustomed to building.

Talks

I've also used the examples listed in this repo and given talks at conferences. If video is your preferred medium of learning, you can head to the links below

360|AnDev 2020: Learning Jetpack Compose By ExampleVideo| Slides

Android Summit 2020: Learn Jetpack Compose By Example v2Slides

Setup

To try out this sample app, you need to at least use the latest versionof Android Studio. This project has been tested against Android Studio Artic Fox.You can download it here.In general, Jetpack Compose requires you to use the Canary version ofAndroid Studio.

Examples

Each example is meant to be self contained and tries to explain all theconcepts that its using with comments. Compose also comes with thisnifty feature that lets you preview each component in the IntelliJ IDEitself. To do so, go to any of the examples and then click onthe preview button in the top right corner. This is possible if your@Composable component has a corresponding @Preview method associatedwith it. Look at the examples below for all this to make a bit moresense.

General

Example Preview
How do I display text on the screen using Jetpack Compose?
How do I make a view clickable and do actions when clicked?
How do I add padding around a view?
How do I add an offset to a layout?
How do I enforce a layout to have a fixed aspect ratio?
How do I add a background color to any section of the screen?
Example 1
Example 2

How do I get FrameLayout like functionality to stack views on top of one another?
How do I do animation in Jetpack Compose?
Example: Rotation Animation
Example: Color Change Animation


How do styles & themes work in Jetpack Compose?
How do I add dark mode capability to my app?

State Management

Example Preview
How do I store state information in Jetpack Compose?
How do I retain state across process death & activity recreation(like orientation changes)?
How do I use LiveData/ViewModels with Jetpack Compose?
How do I use Coroutine Flow to update my components/views with Jetpack Compose?
How do you launch a Coroutine inside a Composable?
How do you do side-effects in Jetpack Compose?
How do you handle back press in Jetpack Compose?

Material Design

Example Preview
How do I add a Material Design Card?
How do I display a linear progress bar?
What about a circular progress bar?
How do I add a Snackbar?
How to add a Material Design Slider?
How to configure a two/three state checkbox?
How do I add a radio button group?
How do I add a Floating Action Button to my screen?
How do I create a Bottom App Bar?
How do I add a drawer to my screen?
How do I add Ripple effect to a view?
How do I add a Button to my screen?
How do I display an alert dialog/popup modal?
How do I make Material Filter Chips that overflow to multiple rows?
How do I add a shadow around my view?

Text

Example Preview
How do I style & customize my text?
How do you take text input from a user in Jetpack Compose?
How can I use a custom text style for a text input?
How can I change the keyboard type to accept numbers?
How can I create a Search bar?
How can I apply a visual transformation to an input text?
How can I provide a hint for the text input field?
Is there filled text field as per Material Design specification?
How do I animate parts of my text?
How do I describe parts of my text to be replaced by alternate views?

Images

Example Preview
How do I display an image in Jetpack Compose?
How to load an image from the resource folder?
How to make an image view with rounded corners?
How to load an image over the network using Picasso?
How to load an image over the network using Glide?

Lists

Example Preview
How do I display a list in my app?
Is there a RecyclerView equivalent?
How can I have a grid layout?
How can I build a horizontally scrollable carousel?
How can I add animations for insertion/deletion of a list item?

Flexible Layouts

Example Preview
How do I align the baseline of two views?

What's the layout weight equivalent in Jetpack Compose?
Example with equal weights
Example with unequal weights

How do I auto arrange my views similar to FlexBox?
Add space between views
Evenly distribute space
Add space around the views
Tightly packed centering of views
How do I use constraint layouts?
How do I use guidelines with constraint layouts?
How do I add barriers when using constraint layouts?
How do I add bias when using constraint layouts?

Custom Views

Example Preview
How do I draw using a canvas?
Example of a measuring scale component
How do I make a view zoomable?
How do I detect touch events in a custom view?

Interoperability

Example Preview
How can I use Jetpack Compose components inside existing screens?

Testing

Example Preview
How do I write a simple UI Test in Jetpack Compose?
How do I test "Composables"?

Credits

Author: Vinay Gaba (vinaygaba@gmail.com)

Follow me on Twitter Follow me on LinkedIn

License

Copyright 2020 Vinay Gaba

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
  • 关于 Jetpack Compose 的学习本想只是简单的快速学习一下,结果万万没想到,竟然一下子折腾了好几个月。。。 下面将之前记录的 Jetpack Compose 相关的学习博文进行一个汇总链接整理,方便我以后自己查阅,也希望能帮到一些有正在学习 Compose 的道友。 Jetpack Compose 中的 state 核心思想 Jetpack Compose 中的 Modifier Je

 相关资料
  • JetBrains 发布的 Jetpack Compose for Desktop 是基于 Google 用于 Android UI 开发的 Jetpack Compose 工具包,Jetpack Compose for Desktop 框架提供了一种声明式和反应性的方法来使用 Kotlin 构建 UI 。 仓库结构 artwork -设计工件 benchmarks -收集基准 ci -持续集成助

  • Jetpack/JetBrains Compose Playground Introduction ��‍♂️ This is an Jetpack Compose example project. I'm collecting a bunch of sample codes for Jetpack Compose. I also collect informations/tutorials on

  • C 是贝尔电话实验室的Dennis M. Ritchie于1972年开发的一种通用的,程序性的,命令式的计算机编程语言,用于开发UNIX操作系统。 C是使用最广泛的计算机语言。 它与Java编程语言一起在第一流程度上保持波动,这也是现代软件程序员中最受欢迎和最广泛使用的Java编程语言。

  • 以下资源包含有关通过示例学习C的其他信息。 请使用它们来获得有关此主题的更多深入知识。 通过示例学习C的有用链接 编译和执行C Online - 高端服务器提供在线编译和执行C程序的机会。 关于K&R2的说明 - K&R2的一个很好的伴侣 C语言程序设计 - C程序设计语言的文学,历史和文化。 学习GNU调试器 - GDB - 调试C和C ++程序中的错误的调试工具。 Unix Makefile

  • C是贝尔电话实验室的Dennis M. Ritchie于1972年开发的一种通用的,程序性的,命令式的计算机编程语言,用于开发UNIX操作系统。 C是使用最广泛的计算机语言。 它与Java编程语言一起在第一流程度上保持波动,这也是现代软件程序员中最受欢迎和最广泛使用的Java编程语言。 听众 (Audience) 本教程是为需要从头开始理解C编程语言的软件程序员而设计的。 本教程将为您提供有关C编

  • 我们有一个遗留应用程序,我们开始迁移到Jetpack Compose。该应用程序只有一个活动,使用带有导航XML图的导航组件在片段之间导航。 我们采取了这一做法: 每次迁移一个片段 为每个片段创建一个@Composable屏幕,该屏幕提供与片段相同的UI 从片段onCreateView()设置内容到新创建的屏幕 现在,假设我们有Fragment1包含一些操作来导航到Fragment2。在原始代码中