Android Material Design之TextInputLayout,TextInputEditText(十四)

  1. 效果图
    在这里插入图片描述
  2. 资源引入
implementation 'com.google.android.material:material:1.4.0'
  1. 属性
TextInputLayout 属性描述
android:id控件id
android:layout_width控件长度
android:layout_height控件高度
app:boxBackgroundColor控件背景颜色
app:boxBackgroundMode控件模式
app:boxStrokeColor控件边框颜色
app:boxStrokeWidth控件边框线宽度
app:hintTextColor控件提示语颜色
app:passwordToggleEnabled显示隐藏输入框密码
app:hintEnabled=“false”默认为true,改为fasle后TextInputEditText 的hint 即可像普通的EditeTextView
TextInputEditText 属性描述
android:id控件id
android:layout_width控件长度
android:layout_height控件高度
android:inputType输入框类型
android:maxLines输入框行数
  1. 源代码
    xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".ui.AdminLoginActivity">

    <LinearLayout
        android:layout_width="@dimen/dp_480"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="@dimen/dp_100"
        android:orientation="vertical">

        <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/text_input_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:boxBackgroundColor="@color/white"
            app:boxBackgroundMode="outline"
            app:boxStrokeColor="@color/c_3c3c3c"
            app:boxStrokeWidth="@dimen/dp_1"
            app:hintTextColor="@color/c_3c3c3c">

            <com.google.android.material.textfield.TextInputEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="请输入账号"
                android:maxLines="1" />
        </com.google.android.material.textfield.TextInputLayout>

        <com.google.android.material.textfield.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/dp_20"
            app:boxBackgroundColor="@color/white"
            app:boxBackgroundMode="outline"
            app:boxStrokeColor="@color/c_3c3c3c"
            app:boxStrokeWidth="@dimen/dp_1"
            app:hintTextColor="@color/c_3c3c3c"
            app:passwordToggleEnabled="true">

            <com.google.android.material.textfield.TextInputEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="请输入密码"
                android:inputType="textPassword"
                android:maxLines="1" />

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

        <com.google.android.material.button.MaterialButton
            android:id="@+id/btn_login"
            android:layout_width="match_parent"
            android:layout_height="@dimen/dp_86"
            android:layout_gravity="center"
            android:layout_marginTop="@dimen/dp_50"
            android:textSize="@dimen/sp_24"
            android:text="登录" />
    </LinearLayout>
</RelativeLayout>
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值