android - 如何创建类似 edittext 布局的 Gmail

标签 android

需要这样的布局 I need layout like this, is there any google api for this layout

最佳答案

您必须将样式 style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" 添加到 TextInputLayout

如果您已经离开 android 支持库并且当前正在使用 Material Design Components .

<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/emailTextInputLayout"
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginStart="@dimen/edit_text_horizontal_margin"
    android:layout_marginEnd="@dimen/edit_text_horizontal_margin"
    android:layout_marginBottom="@dimen/edit_text_vertical_margin"
    android:hint="Username"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/emailTextInputEditText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textEmailAddress" />

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

如果没有,我建议您阅读我写的关于如何 migrate to Material Design Components 的文章.

旧答案:

例如:

<android.support.design.widget.TextInputLayout
    android:id="@+id/emailTextInputLayout"
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginStart="@dimen/edit_text_horizontal_margin"
    android:layout_marginEnd="@dimen/edit_text_horizontal_margin"
    android:layout_marginBottom="@dimen/edit_text_vertical_margin"
    android:hint="Username"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <android.support.design.widget.TextInputEditText
        android:id="@+id/emailTextInputEditText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textEmailAddress" />

</android.support.design.widget.TextInputLayout>

关于android - 如何创建类似 edittext 布局的 Gmail,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55314966/

相关文章:

android - setExposureCompensation 在三星 Galaxy s3 中不起作用

java - android:如何使用Retrofit从以下json接收响应?

java - libGDX - 以有效的方式制造脚步

android - setvisibility(view.visible) 在 setvisibility(view.gone) 之后不工作

java - Android : How can i interface between . java文件和GSOAP

android - 在android中创建音频文件的波形

java - 创建新 Activity 后 TextView 不更新

java - 通过 Android 从 ble 设备发送和接收数据

android - Toast 未在 Samsung Galaxy S3 上显示(最新更新 4.1.2)

Android 谷歌地图 API - 取消焦点标记监听器