OutlinedBox TextInputLayout and gravity center?

后端 未结 2 862
别跟我提以往
别跟我提以往 2021-01-17 08:33

How to achieve centered new OutlinedBox style with TextInputLayout?

Current behavior:



        
相关标签:
2条回答
  • 2021-01-17 09:26

    Centered Text inside an outlined textfield isn't really a case we support. It's not actually mentioned at all in the guidance (https://material.io/design/components/text-fields.html)

    It does look like a bug that the label text is centered when center gravity is applied. The easiest way to get that fixed would be to send a pr to us with the fix on https://github.com/material-components/material-components-android. Or you can file a bug here: https://issuetracker.google.com/issues/new?component=439535.

    0 讨论(0)
  • 2021-01-17 09:40

    With the Material Components Library, starting from the version 1.2.0-alpha02 the collapsed label position is determined via the edit text gravity.

    Using something like:

    <com.google.android.material.textfield.TextInputLayout
        android:hint="@string/...."
        ...>
    
        <com.google.android.material.textfield.TextInputEditText
            android:gravity="center"
            ../>
    
    </com.google.android.material.textfield.TextInputLayout>
    

    The result is:

    0 讨论(0)
提交回复
热议问题