我读过类似问题的不同答案,但它们都是旧的,并且似乎不适用于最新版本的 MUI。
我需要在 div 上应用触摸波纹效果,但我无法使用按钮或元素,ButtonBase因为其中还有另一个按钮。
预先感谢您的回复。
在这个答案中,我弄错了波纹动画。您知道如何使用 Jetpack Compose 创建带有圆角的波纹吗?
使用默认波纹我有这个:

代码:
Card(shape = RoundedCornerShape(30.dp),
border = BorderStroke(width = 2.dp, color = buttonColor(LocalContext.current)),
backgroundColor = backColor(LocalContext.current),
modifier = Modifier
.fillMaxWidth()
.padding(10.dp)
.clickable(
interactionSource = remember { MutableInteractionSource() },
indication = rememberRipple(radius = 30.dp)
) { show = !show }
) { ... } //Show is animation of other element.
Run Code Online (Sandbox Code Playgroud)
//如果我放波纹半径200 dp(它是卡片的高度)波纹效果不正常。
我想使用该功能,但LongPressDown遗憾的是,手势检测器没有波纹触摸效果。所以如果我选择使用LongPressDownDetailsGestureDetectorInkWell它,则没有 LongPressDownDetails。
所以我的问题是,如何利用 GestureDetector 的功能获得 InkWell 的涟漪效果?
我做了一个简单的应用程序。它有两个屏幕:onBoarding 和 homeScreen:
@Composable
fun DigitalBanking() {
var shouldShowOnBoarding by rememberSaveable { mutableStateOf(true) }
if (shouldShowOnBoarding) {
OnBoardingScreen {
shouldShowOnBoarding = false
}
} else {
MainScreen()
}
}
@Composable
fun OnBoardingScreen(
onClick: () -> Unit
) {
Surface {
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Top,
horizontalAlignment = Alignment.CenterHorizontally
) {
Box(
modifier = Modifier
.fillMaxSize()
.background(color = MaterialTheme.colors.onBackground)
)
{
Image(
painter = painterResource(id = R.drawable.starting_screen),
contentDescription = null,
modifier = Modifier
.fillMaxSize()
.padding(bottom = 160.dp)
)
Column( …Run Code Online (Sandbox Code Playgroud)