我正在使用selectableItemBackgroundBorderless添加波纹ImageView.我的预期行为是圆形波纹,扩大视图大小.不幸的是,波纹被视角限制.如何解决这个问题?
默认状态:
压制状态:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/nav_instruction_container"
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:background="@drawable/nav_gradient_bg"
android:padding="20dp">
<ImageView
android:id="@+id/nav_sign"
android:layout_width="wrap_content"
android:layout_height="46dp"
android:layout_centerVertical="true"
android:scaleType="centerInside"
android:adjustViewBounds="true"
/>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/nav_sign"
android:layout_marginLeft="24dp"
android:layout_marginStart="24dp"
android:layout_marginRight="24dp"
android:layout_marginEnd="24dp"
android:textColor="@color/white"
android:textSize="24sp"
android:textStyle="bold"
android:maxLines="2"
tools:text="A644 Shudehill asdfkjasdf asdfasdf asdfsss"
android:ellipsize="marquee"
/>
<TextView
android:id="@+id/subTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/title"
android:layout_toRightOf="@+id/nav_sign"
android:layout_marginLeft="24dp"
android:layout_marginStart="24dp"
android:layout_marginRight="24dp"
android:layout_marginEnd="24dp"
android:textColor="@color/white"
android:textSize="17sp"
tools:text="via Church St"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
app:srcCompat="@drawable/ic_nav_queue_sheet_icon_light"
android:id="@+id/nav_queue"
android:scaleType="centerInside"
android:foreground="?attr/selectableItemBackgroundBorderless"
android:adjustViewBounds="true"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud) android android-button android-view material-design rippledrawable
在这个答案中,我弄错了波纹动画。您知道如何使用 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(它是卡片的高度)波纹效果不正常。
如何更改 IconButton 的波纹颜色?
我尝试这样做,但它没有改变:
IconButton(
onClick = { onClick() },
modifier = Modifier.clickable(
onClick = { onClick() },
indication = rememberRipple(color = MyCustomTheme.colors.primary),
interactionSource = remember { MutableInteractionSource() },
)
)
Run Code Online (Sandbox Code Playgroud) android android-jetpack-compose android-jetpack-compose-button