gpt4 book ai didi

android - 自定义文本输入布局

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:36:10 24 4
gpt4 key购买 nike

我想将边框应用于 TextInputLayout,如图所示。

现在我已经这样实现了。

enter image description here

但是,我想要如下图所示(即标签放置在边框内)。

enter image description here

我为 EditText 实现的代码如下。

<customviews.MyEditText
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/edittext_border_background"
android:layout_marginEnd="30dp"
android:layout_marginStart="30dp"
android:layout_marginTop="45dp"
android:gravity="start"
android:hint="@string/hint_username"
android:imeOptions="actionNext|actionDone"
android:inputType="textEmailAddress|text"
android:padding="10dp"
android:textColor="@color/primary_text"
android:textColorHint="@color/secondary_text"
android:textSize="16sp"
/>

并且,对于边框,我应用了背景 editetext_border_background.xml 如下

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
android:padding="20dp">
<solid android:color="#FFFFFF"/>
<corners
android:bottomRightRadius="0dp"
android:bottomLeftRadius="0dp"
android:topLeftRadius="0dp"
android:topRightRadius="0dp"/>
<stroke
android:width="1dip"
android:color="@color/primary" />

</shape>

当我尝试将边框应用于 TextInputLayout 时,它没有提供预期的输出。

enter image description here

谁能帮帮我??

最佳答案

您应该为 Outline Box 使用 Material Design 风格。简单使用:

style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"

TextInputLayout 中。请参阅 Material Design Guide 中的 Android 文本字段

enter image description here

关于android - 自定义文本输入布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47172235/

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