Joseph Cheng
01/31/2020, 4:59 AMPressIndicatorGestureDetector
, like Ripple
to customize one.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:color="#ffff0000"/> <!-- pressed -->
<item android:state_focused="true"
android:color="#ff0000ff"/> <!-- focused -->
<item android:color="#ff000000"/> <!-- default -->
</selector>
Joseph Cheng
01/31/2020, 7:32 AMPressIndicatorGestureDetector
will consume the down events. It cannot combine it with Ripple
. I cannot figure out a better way to fix this problem.
@Composable
fun Selector(
enabled: Boolean = true,
children: @Composable() (active: Boolean) -> Unit
) {
var active by state { false }
PressIndicatorGestureDetector(
onStart = { active = true },
onStop = { active = false },
onCancel = { active = false },
enabled = enabled,
children = { children(active) }
)
}
Ian Warwick
01/31/2020, 8:40 AMClickable(onClick = { state = !state }) { children(active) }
work here?Joseph Cheng
01/31/2020, 12:17 PMClickable
only triggers when user released the finger not press the finger. This is not what I expected.