gpt4 book ai didi

android - OutlinedBox TextInputLayout 和重心?

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:14:12 34 4
gpt4 key购买 nike

如何使用 TextInputLayout 实现居中的新 OutlinedBox 样式?

当前行为:

left and center

<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 吗?

最佳答案

随着Material Components Library ,从版本 1.2.0-alpha02 开始,折叠标签位置通过编辑文本 gravity 确定。

使用类似的东西:

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

<com.google.android.material.textfield.TextInputEditText
android:gravity="center"
../>

</com.google.android.material.textfield.TextInputLayout>

结果是:

enter image description here

关于android - OutlinedBox TextInputLayout 和重心?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53413119/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com