Skip to content

[TextInputLayout] Prefix not displayed for the first time #3070

Open
@garret1evg

Description

@garret1evg

Description: Prefix not displayed for the first time

In Binding Adapter prefix appeared from second call

@BindingAdapter(
    value = ["zeroSalaryPlaceholder", "negativeSalaryPrefixByArticle", "negativeSalaryPrefixByArticleLogWorkType"],
    requireAll = true
)
fun bindZeroSalaryPlaceholder(
    view: OneLineEditableItem,
    inputText: String?,
    digit: Float?,
    logWorkType: LogWorkType?
) =
    view.apply {
        inputText?.let { enteredText ->
            when {
                enteredText.isNotEmpty() && ((logWorkType == LogWorkType.Deduction) || (digit != null && digit < 0F)) -> {
                    setZeroPlaceholder(null)
                    setTextPrefix("-")
                }
                enteredText.isEmpty() -> {
                    setTextPrefix(null)
                    setZeroPlaceholder(R.string.amount)
                }
                else -> Unit
            }
        }
    }

fun setTextPrefix(prefix: String?) = binding.apply { itemOneLineTextLayout.prefixText = prefix }

image

image

image

Expected behavior: prefix appeared from FIRST call

Source code: I think this code working wrong, because startLayout.getMeasuredWidth() still 0 when we have getPrefixText() not null, that's why prefix not displayed.

Android API version: Android API 30

Material Library version: 1.8.0-alpha02, 1.8.0-alpha01, 1.7.0

Device: Emulator and Physical

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions