17

TextInputLayoutで中央揃えの新しいOutlinedBoxスタイルを実現するにはどうすればよいですか?

現在の動作:

左と中央

<android.support.design.widget.TextInputLayout
    android:id="@+id/textInputLayout2"
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="left"
    >
    <android.support.design.widget.TextInputEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="left"
        android:hint="hint"
        />
</android.support.design.widget.TextInputLayout>

<android.support.design.widget.TextInputLayout
    android:id="@+id/textInputLayout"
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    >
    <android.support.design.widget.TextInputEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:hint="hint2"
        />
</android.support.design.widget.TextInputLayout>

私は使用しますcom.android.support:design:28.0.0

中央揃えの通常の TextInputEditText を実装するアイデアはありますか?

4

2 に答える 2

0

アウトライン化されたテキスト フィールド内の中央揃えのテキストは、実際にはサポートされていません。ガイダンスでは実際にはまったく言及されていません(https://material.io/design/components/text-fields.html

中心重心を適用すると、ラベルのテキストが中央に表示されるのはバグのようです。これを修正する最も簡単な方法は、 https://github.com/material-components/material-components-androidで修正を含む pr を送信することです。または、 https ://issuetracker.google.com/issues/new?component=439535 でバグを報告できます。

于 2018-11-30T15:42:21.643 に答える