forgive me if it has been answered but I didn't fi...
# compose-android
g
forgive me if it has been answered but I didn't find any result when I searched. Is it possible to reduce the padding of the
trailingIcon
in an OutlinedTextField?
👍 1
Copy code
BasicTextField(
            modifier = Modifier
                .weight(1f)
                .onFocusChanged {
                    onFocusChanged?.invoke(it)
                },
            value = value,
            onValueChange = onValueChanged,
            singleLine = singleLine,
            textStyle = MyTheme.typography.body1Regular,
            keyboardActions = keyboardActions,
            keyboardOptions = keyboardOptions,
        ) {
            OutlinedTextFieldDefaults.DecorationBox(
                value = value,
                innerTextField = it,
                singleLine = singleLine,
                enabled = true,
                visualTransformation = VisualTransformation.None,
                placeholder = {
                    hint?.let {
                        Text(
                            text = it,
                            style = MyTheme.typography.body1Regular,
                            color = hintColor ?: MyTheme.colors.gray1
                        )
                    }
                },
                trailingIcon = trailingIcon,
                isError = error != null,
                interactionSource = interactionSource,
                contentPadding = // <----- something to pass here?
            )
        }
I try to use BasicTextField but still dont know how to change the padding inside the trailing icon
c
You're most of the way there - passing your own contentPadding param for DecorationBox should do the trick. Other material composables that have a default value for icon padding usually just change the
start
and
end
value in PaddingValues to a different value
g
This message contains interactive elements.
c
Ah ok - I don't think that can be changed why still using Material components. That's my impression based on the internal implementation of
OutlinedTextFieldLayout
, which has no parameter to change the minimum size of the Box around the trailingIcon. However, the minimum size is set at 48.dp - which is about the smallest size a person could reasonably click on.