我有 AnimatedVisibility 的简单动画(slideInVertically/SlideOut)。当我按下“nextScreenButton”时,我通过 navController 进行新的导航。转换是立即完成的,因此没有时间执行退出动画。如何等待动画结束
我可以输入一些动画时间延迟,但这不是好方法。
代码:
Scaffold() {
AnimatedVisibility(
//Boolean State for open animation
OpenChooseProfilePageAnim.value,
initiallyVisible= false,
enter = slideInVertically(
initialOffsetY = { fullHeight -> fullHeight },
animationSpec = tween(
durationMillis = 3000,
easing = LinearOutSlowInEasing
)
),
exit = slideOutVertically(
targetOffsetY = { fullHeight -> fullHeight },
animationSpec = tween(
durationMillis = 3000,
easing = LinearOutSlowInEasing
)
)
) {
ConstraintLayout() {
Card() {
Column() {
//Some other Composable items
//Composable button
NextScreenButton() {
//calling navigation here
} …Run Code Online (Sandbox Code Playgroud) 也许有人可以告诉我如何在 Switch() 中设置 TrackWidth、TrackStrokeWidth、ThumbDiameter 的大小
Switch(
modifier = Modifier
.padding(end=16.dp),
checked = auto.mainAuto.value,
onCheckedChange = { auto.mainAuto.value = it },
colors = SwitchDefaults.colors(
checkedThumbColor = white_white,
checkedTrackColor = Accent_Blue,
uncheckedThumbColor = white_white,
uncheckedTrackColor = Disabled_Text,
),
)
Run Code Online (Sandbox Code Playgroud) 导航结构:
MainActivity
|- nav_root
|- HomeFragment
|- AuthNestedGraph
| |- nav_auth
| | |-BeforeOtpFragment(home)
| | |-OtpFragment
|
|- ProfileNestedGraph
| |- nav_prfole
| | |-ProfileFragmentOne(home)
| | |-ProfileFragmentTwo
Run Code Online (Sandbox Code Playgroud)
我可以从 HomeFragment 导航到 BeforeOtp(nav_auth home)、toProfileOne(nav_profile home)。我还可以通过全局 id 从任何 auth 片段导航到 toProfileOne,或从配置文件片段导航到 BeforeOtp
但是如何导航到另一个嵌套图形/导航文件中未从片段设置为 home 的子片段?类似于 OtpFragment/ProfileTwoFragment。如何更改导航控制器?
尝试全局时出现异常:“无法从当前目的地找到”
我可以通过深层链接来做到这一点,但这不是我正在寻找的解决方案。
navigation android parent-child android-architecture-navigation android-jetpack-navigation
我有五个文本字段。在第一个字段中输入内容后,焦点将移动到下一个文本字段。如果我删除了文本字段中的某些内容 - 焦点会移动到上一个文本字段。所有具有焦点的工作都经过 onValueChanged 部分
但是,如果文本字段中的值为空白(“”) - 如果我在键盘中按退格键,则 onValueChanged 不会发生任何情况,因为字段中的值未更改。我需要以某种方式将焦点集中在前一个文本字段上
那么我如何在撰写文本字段的软键盘中使用侦听器进行后按?
我尝试使用 KeyboardActions,
keyboardActions = KeyboardActions(
onPrevious = {
//some work with foucs
},
),
Run Code Online (Sandbox Code Playgroud)
但它不起作用
第二个问题:如果文本字段被单击(或获得焦点),如何在结束文本的字段中设置光标?
即使用户单击字符串光标中间的设置,我也需要。
android event-listener textfield kotlin android-jetpack-compose
想为电话号码创建文本字段。需要帮助将字段中的光标设置为始终位于字符串末尾
我想要做什么:当在字段中获得新数字时,我获取已输入的所有数字,然后附加下划线(_)以获得至少11个字符串长度,然后通过子字符串返回带有数字或“_”的字符串:
return "+7(${template.substring(1, 4)}) ${template.substring(4,7)} ${template.substring(7,9)} ${template.substring(9, 11)}"
如果光标始终位于末尾,则它可以工作,但如果不是,则数字顺序被破坏
完整代码:
@Composeble
@Composable
fun PhoneNumberEditText(
phoneNumState: MutableState<String>,
modifier: Modifier = Modifier,
imeAction: ImeAction = ImeAction.Done,
onImeAction: () -> Unit = {}
) {
TextField(
shape = RoundedCornerShape(16.dp),
value = phoneNumState.value,
onValueChange = { value ->
phoneNumState.value = value
val digits = phoneNumState.value.toCharArray().filter { it.isDigit() }
phoneNumState.value = phoneNumTemplate(digits)
},
modifier = modifier
.clip(RoundedCornerShape(16.dp))
.size(343.dp, 54.dp),
singleLine = true,
placeholder = {
Text(
"+7(___)_______", style = passwordTextStyle,
)
},
colors = …Run Code Online (Sandbox Code Playgroud) android phone-number textfield android-jetpack-compose android-compose-textfield
android ×4
textfield ×2
android-architecture-navigation ×1
kotlin ×1
navigation ×1
parent-child ×1
phone-number ×1
uiswitch ×1