flymetwothemoon / listincompose Goto Github PK
View Code? Open in Web Editor NEW学习compose中的列表和状态
学习compose中的列表和状态
学习了compose中的列表和状态,列表和Android中的recyclerView和listView的使用效果差不多,但是compose是用kotlin写的,kotlin一般都喜欢和拉姆达表达式一块连用,当给列表中的每一个元素赋值的时候,确实比recyclerview简单 状态我感觉是用来保存一个变量的状态,这次写的demo中状态就是为了保存你是否点击过列表中的元素,如果该元素没被点击则为false,若该元素被点击则为true 这个demo主要就是实现一个类似recyclerview的东西,并且实现了如果没点之前最多是1行,点击之后则把所有的字都显示出来 遇到的一个疑惑 没看到后面,感觉remember能保存的不会太多,我第一次点第一个让它的字体变了一个颜色,刷到下面然后再往回去看,字体颜色变回去了 动画 在该demo中,它的动画主要体现在按字的时候字体的颜色会逐渐发生变化,虽然我看不出来 用val surfaceColor:Color by animateColorAsState(if(isExpanded) MaterialTheme.colors.primary else MaterialTheme.colors.secondary) 该段代码,让按之前字体的颜色是MaterialTheme.colors.secondary,按之后是 MaterialTheme.colors.primary,用surface把你要进行变化的那段字包裹起来 shape = MaterialTheme.shapes.small, //large直接没有弧度,medium有一点弧度,small的弧度最大 elevation = 100.dp, //设置阴影大小 modifier = Modifier.animateContentSize().padding(1.dp)//这个是真不知道干嘛用的,唯一一点就是我改变padding里面的dp大小,不用进行重新编译,就会进行变化
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.