Skip to content

Instantly share code, notes, and snippets.

View droid-it's full-sized avatar

Udit droid-it

  • India
View GitHub Profile
@Composable
fun FixedLazyGrid() {
val colors = remember {
listOf(Color.Yellow, Color.LightGray, Color.Cyan)
}
LazyVerticalGrid(
columns = GridCells.Fixed(5),
content = {
for (i in 0..20) {
item {
@Composable
fun FlowRowSample() {
val colors = remember {
listOf(Color.Yellow, Color.LightGray, Color.Cyan)
}
Box(modifier = Modifier.padding(4.dp)) {
FlowRow {
for (i in 0..10) {
Box(
modifier = Modifier
// gradle dependecies (app.gradle)
dependencies {
implementation "androidx.compose.material3:material3:<latest_version>"
implementation "androidx.compose.material3:material3-window-size-class:<latest_version>"
}
// Activity
class MainActivity : ComponentActivity() {
@Composable
fun Timer() {
val timerDuration = 5000L
println("Composing Timer")
LaunchedEffect(key1 = Unit, block = {
startTimer(timerDuration) {
println("Timer ended")
}
})
}
@Composable
fun TimerScreen() {
val scope = rememberCoroutineScope()
Column {
Button(onClick = {
println("Timer started")
scope.launch {
try {
startTimer(5000) {
println("Timer ended")
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="240dp"
android:padding="8dp">
<android.support.constraint.Guideline
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:showIn="@layout/activity_main">
<android.support.constraint.Guideline
@droid-it
droid-it / constraint_layout_adaptive.xml
Last active June 11, 2018 12:19
Constraint Layout example with adaptive constraints
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="200dp"
tools:context=".MainActivity">
<android.support.constraint.Guideline
android:id="@+id/titleTextViewGuideline"
@droid-it
droid-it / constraint_layout_wrt_parent.xml
Last active June 8, 2018 10:23
ConstraintLayout where every child is defined with respect to its parent
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
tools:context=".MainActivity">
<TextView