Skip to content

Commit 30d0bd8

Browse files
Implemented scrolls;
1 parent a117d37 commit 30d0bd8

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

app/src/main/java/xyz/teamgravity/nestedscroll/MainActivity.kt

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,20 @@ package xyz.teamgravity.nestedscroll
33
import android.os.Bundle
44
import androidx.activity.ComponentActivity
55
import androidx.activity.compose.setContent
6-
import androidx.compose.foundation.layout.fillMaxSize
6+
import androidx.compose.foundation.BorderStroke
7+
import androidx.compose.foundation.background
8+
import androidx.compose.foundation.border
9+
import androidx.compose.foundation.layout.*
10+
import androidx.compose.foundation.lazy.LazyColumn
11+
import androidx.compose.foundation.lazy.LazyListScope
12+
import androidx.compose.foundation.lazy.LazyRow
713
import androidx.compose.material3.MaterialTheme
814
import androidx.compose.material3.Surface
15+
import androidx.compose.material3.Text
16+
import androidx.compose.runtime.Composable
917
import androidx.compose.ui.Modifier
18+
import androidx.compose.ui.graphics.Color
19+
import androidx.compose.ui.unit.dp
1020
import xyz.teamgravity.nestedscroll.ui.theme.NestedScrollTheme
1121

1222
class MainActivity : ComponentActivity() {
@@ -19,8 +29,46 @@ class MainActivity : ComponentActivity() {
1929
modifier = Modifier.fillMaxSize(),
2030
color = MaterialTheme.colorScheme.background
2131
) {
32+
LazyColumn {
33+
item {
34+
SubList1()
35+
}
36+
37+
Sublist2()
38+
39+
item {
40+
SubList1()
41+
}
42+
}
2243
}
2344
}
2445
}
2546
}
47+
}
48+
49+
@Composable
50+
fun SubList1() {
51+
LazyRow {
52+
items(10) {
53+
Box(
54+
modifier = Modifier
55+
.size(100.dp)
56+
.padding(10.dp)
57+
.background(Color.Red)
58+
)
59+
}
60+
}
61+
}
62+
63+
fun LazyListScope.Sublist2() {
64+
items(20) { index ->
65+
Text(
66+
text = index.toString(),
67+
modifier = Modifier
68+
.fillMaxWidth()
69+
.padding(horizontal = 10.dp)
70+
.border(BorderStroke(1.dp, Color.Red))
71+
.padding(20.dp)
72+
)
73+
}
2674
}

0 commit comments

Comments
 (0)