streetsofboston
10/07/2020, 2:38 PMclipChildren=false
and clipToPadding=false
?Adam Powell
10/07/2020, 2:41 PMstreetsofboston
10/07/2020, 2:42 PMAdam Powell
10/07/2020, 2:43 PMstreetsofboston
10/07/2020, 2:44 PMclass MainActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val listData = List(20) { "Item ${it + 1}" }
findViewById<ComposeView>(R.id.compose_view).setContent {
WearOSPrototypeTheme(themeParameters = createMdcTheme(ContextAmbient.current)) {
MyListView(listData)
}
}
}
}
@Composable
fun MyListView(names: List<String>) {
val listState = rememberLazyListState()
LazyColumnForIndexed(
items = names,
state = listState,
modifier = Modifier
.fillMaxHeight()
.fillMaxWidth()
.drawLayer(clip = false)
) { index, item ->
val itemHeight = 126.0f
val halfItemHeight = itemHeight / 2f
val diffIndex = index - listState.firstVisibleItemIndex
val minScale = 0.75f
val minAlpha = 0.5f
val sp = when (diffIndex) {
0 -> 0f
1 -> 1 - abs((listState.firstVisibleItemScrollOffset - halfItemHeight) / halfItemHeight)
2 -> 0f
else -> 0f
}
Surface(
color = Color.DarkGray,
modifier = Modifier
.drawLayer(
scaleX = interpolate(minScale, 1.33f, sp),
scaleY = interpolate(minScale, 1.33f, sp),
alpha = interpolate(minAlpha, 1f, sp),
clip = false
)
) {
ListItem(
modifier = Modifier
.padding(vertical = 4.dp, horizontal = 0.dp)
.fillParentMaxWidth()
) {
Text(text = item)
}
}
}
}
Andrey Kulikov
10/07/2020, 2:59 PMstreetsofboston
10/07/2020, 3:00 PMComposeView
LazyColumnForIndex
Adam Powell
10/07/2020, 3:53 PMstreetsofboston
10/07/2020, 4:13 PMAndrey Kulikov
10/07/2020, 6:50 PMfindViewById<ComposeView>(R.id.compose_view)
probably has the same size as LazyColumnForIndex
and it is clipping. try to make clipChildren = false on it(and maybe on its parent as well, I don't know what is your layout)streetsofboston
10/07/2020, 7:45 PMpadding
methods, the items are clipped as well.