is it possible to prevent the TextField from scrolling and hiding the text? I think scrolling should...
o
is it possible to prevent the TextField from scrolling and hiding the text? I think scrolling should be available only when the text is wider than the width of the field but in the case here it should be static, especially since it’s just whitespace afterwards, using
.width(IntrinsicSize.Min)
to wrap the content (code in thread)
Copy code
Row(
    modifier = modifier
        .align(Alignment.TopCenter)
        .fillMaxWidth()
        .padding(horizontal = 40.dp),
    verticalAlignment = Alignment.CenterVertically,
    horizontalArrangement = Arrangement.Center
) {

    Text(
        text = "$",
        style = AppTheme.typography.display,
    )

    BasicTextField(
        modifier = modifier
            .weight(1f, false)
            .width(IntrinsicSize.Min)
            .focusRequester(focusRequester),
        value = textFieldValue,
        onValueChange = onValueChange,
        interactionSource = interactionSource,
        singleLine = true,
        textStyle = AppTheme.typography.display.copy(
            fontSize = textSizeAnim.sp,
            color = color
        ),
        keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
    ) { innerTextField ->
        TextFieldDefaults.TextFieldDecorationBox(
            value = textFieldValue.text,
            innerTextField = innerTextField,
            singleLine = true,
            visualTransformation = VisualTransformation.None,
            interactionSource = interactionSource,
            contentPadding = PaddingValues(0.dp),
            enabled = true,
            placeholder = {
                Text(
                    text = "0",
                    style = AppTheme.typography.display.copy(
                        fontSize = textSizeAnim.sp,
                        textAlign = TextAlign.Center,
                    ),
                    color = AppTheme.colors.dark,
                    textAlign = TextAlign.Center
                )
            }
        )
    }
}
f
haven’t tried it yet, but do you think overriding the InteractionSource and disabling the drag there would work?
220 Views