gpt4 book ai didi

android - 带圆角的 TextInputLayout

转载 作者:行者123 更新时间:2023-12-05 04:58:42 33 4
gpt4 key购买 nike

如何为登录表单制作圆角?这是我的代码:

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/editLoginWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/appTitle"
android:layout_marginBottom="8dp"
android:layout_marginTop="18dp">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/editLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:backgroundTint="#FFFFFF"
android:hint="@string/login_hint"
android:inputType="text"
android:textColor="#000000"
android:padding="7dp"
android:textColorLink="#FFFFFF" />

尝试添加:

style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
app:endIconMode="password_toggle"
app:boxCornerRadiusBottomEnd="8dp"
app:boxCornerRadiusTopEnd="8dp"
app:boxCornerRadiusBottomStart="8dp"
app:boxCornerRadiusTopStart="8dp"

如所述here但这没有任何区别-角落不会变圆。怎么了?

最佳答案

删除 TextInputEditText 中的 android:background="#FFFFFF"android:backgroundTint="#FFFFFF"

使用:

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/editLoginWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/appTitle"
android:layout_marginBottom="8dp"
android:hint="Login"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
app:endIconMode="password_toggle"
app:boxCornerRadiusBottomEnd="8dp"
app:boxCornerRadiusTopEnd="8dp"
app:boxCornerRadiusBottomStart="8dp"
app:boxCornerRadiusTopStart="8dp"
android:layout_marginTop="18dp">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/editLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:textColor="#000000"
android:padding="7dp"
android:textColorLink="#FFFFFF" />

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

enter image description here

您还可以使用 shapeAppearanceOverlay 属性来代替声明所有的角:

<com.google.android.material.textfield.TextInputLayout
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.App.rounded"

与:

  <style name="ShapeAppearanceOverlay.App.rounded" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">8dp</item>
</style>

关于android - 带圆角的 TextInputLayout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63851573/

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