TextInputLayout学习

enforceMaterialTheme 强制执行材料主题
materialThemeOverlay 材质主题叠加
enforceTextAppearance 强制文本外观
boxBackgroundMode 框背景模式
boxStrokeColor 框描边颜色
passwordToggleDrawable 密码切换可绘制
passwordToggleTint 密码切换色调
passwordToggleContentDescription 密码 切换 内容 描述
endIconTint 结束图标色调
startIconTint 开始图标色调
counterTextAppearance 计数器本外观
counterOverflowTextAppearance 计数器溢出文本外观
errorTextAppearance 错误文本外观
helperTextTextAppearance 辅助文本文本外观
hintTextAppearance 提示文本外观
counterTextColor 计数器文本颜色
counterOverflowTextColor 计数器溢出文

本颜色
errorTextColor 错误文本颜色
helperTextTextColor 辅助文本颜色
hintTextColor 提示文本颜色
shapeAppearance 外形外观
shapeAppearanceOverlay 形状外观叠加






这个属性需要学习下

<item name="boxStrokeErrorColor">@color/mtrl_error</item>
<item name="boxStrokeWidth">@dimen/mtrl_textinput_box_stroke_width_default</item>
<item name="boxStrokeWidthFocused">@dimen/mtrl_textinput_box_stroke_width_focused</item>


app:boxStrokeColor="@android:color/transparent"
app:boxBackgroundColor="@android:color/transparent"


<item name="boxStrokeWidth">2dp</item>
mtrl_textinput_outline_box_expanded_padding  
mtrl_textinput_box_corner_radius_small
mtrl_textinput_box_corner_radius_medium
mtrl_textinput_box_stroke_width_default
mtrl_textinput_box_stroke_width_focused
mtrl_textinput_box_label_cutout_padding




<attr name="startIconTintMode">
      <!-- The tint is drawn on top of the drawable.
           [Sa + (1 - Sa)*Da, Rc = Sc + (1 - Sa)*Dc] -->
      <enum name="src_over" value="3"/>
      <!-- The tint is masked by the alpha channel of the drawable. The drawable’s
           color channels are thrown out. [Sa * Da, Sc * Da] -->
      <enum name="src_in" value="5"/>
      <!-- The tint is drawn above the drawable, but with the drawable’s alpha
           channel masking the result. [Da, Sc * Da + (1 - Sa) * Dc] -->
      <enum name="src_atop" value="9"/>
      <!-- Multiplies the color and alpha channels of the drawable with those of
           the tint. [Sa * Da, Sc * Dc] -->
      <enum name="multiply" value="14"/>
      <!-- [Sa + Da - Sa * Da, Sc + Dc - Sc * Dc] -->
      <enum name="screen" value="15"/>
    </attr>















app:counterEnabled="true"

        计数器的最大长度  
        app:counterMaxLength="11"

        计数器正常状态样式 
        app:counterTextAppearance="@style/CounterStyle"  

        计数器越位状态样式 
        app:counterOverflowTextAppearance="@style/CounterOverflowStyle"








setError后 hint的颜色会变红,仅管设置了app:hintTextColor="@android:color/darker_gray"
app:hintTextAppearance="@style/MyStyle"

<style name="MyStyle" parent="Theme.AppCompat.Light">
    <item name="colorControlNormal">#6F3FFF</item>
    <item name="colorControlActivated">#00FF00</item>
    <item name="android:textColor">#00FFFF</item>
    <item name="android:textSize">31sp</item>
  </style>

也不行!




app:hintTextAppearance="@style/MyStyle"//设置hint的文本属性,改变hint文字的大小颜色等属性



android:inputType="textPassword"
app:endIconMode="password_toggle"
app:passwordToggleEnabled="true" (默认是眼睛,须配合 EditText inputType=”textPassword”等密文type)
app:passwordToggleDrawable="@drawable/password_visible_invisible"


Value to use for the EditText's collapsed top padding in box mode.
作用是啥?没试出来?
app:boxCollapsedPaddingTop="10dp" ?

这两个的用法待定


app:startIconTint="@color/cardview_dark_background"
app:startIconTintMode="src_in"

使输入框和下边的线始终左右对齐,输入框两边没有padding


让输入框和右边的自定义图标在一条线上,使用输入框的paddingTop和paddingBottom 相同,或都不设置(具体看theme中是否设置了)

    android:paddingTop="1dp"
    android:paddingBottom="1dp"

输入框没有背景和下划线,并且它和右边的自定义图标在一条线上,当单击【显示错误按钮时】让自定义图标保持当前状态不变(不变为红色的图标)

app:padding="0dip"
app:boxBackgroundMode="none"
app:errorIconDrawable="@null"
 app:endIconMode="clear_text"
 app:endIconDrawable="@drawable/ic_clock_black_24dp" 

<com.google.android.material.textfield.TextInputLayout
    android:layout_width="@dimen/material_textinput_default_width"
    android:layout_height="wrap_content"
    android:id="@+id/TextInputLayout_end"
    android:layout_margin="4dp"
    android:layout_gravity="center_horizontal"
    android:hint="@string/cat_textfield_label"
    app:errorEnabled="true"
    app:helperText="@string/cat_textfield_outlined_suffix_icon_helper_text"
    app:hintEnabled="false"
    app:helperTextEnabled="true"
    app:endIconMode="clear_text"
    app:endIconDrawable="@drawable/ic_clock_black_24dp"
    app:boxBackgroundMode="none"
    app:boxCollapsedPaddingTop="0dp"
    app:boxCornerRadiusBottomEnd="10dp"
    app:boxCornerRadiusBottomStart="10dp"
    app:boxCornerRadiusTopStart="10dp"
    app:boxCornerRadiusTopEnd="10dp"
      >
<!--    app:suffixText="@string/cat_textfield_suffix"-->
    <com.google.android.material.textfield.TextInputEditText
      android:paddingTop="1dp"
      android:paddingBottom="1dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="end"
        android:textAlignment="textStart"
        android:inputType="numberDecimal"/>
  </com.google.android.material.textfield.TextInputLayout>


app:boxBackgroundMode="filled" 模式下修改,输入框处于
得到焦点 或失去 焦点 或 错误情况下,让输入框下边的线始终处1个dp的高度,并且 颜色不变,


app:boxStrokeColor="@android:color/transparent"
    app:boxBackgroundColor="@android:color/transparent"
    app:boxStrokeErrorColor="@android:color/transparent"
    app:boxStrokeWidth="1dp"
    app:boxStrokeWidthFocused="1dp"
    app:boxBackgroundMode="filled"












EditText setError图标和endIconMode已融合

一个快速的解决方案是使用填充将错误消息向左移动。

<com.google.android.material.textfield.TextInputEditText
                android:id="@+id/passwordEditText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:paddingRight="40dp"
                android:inputType="textPassword" />
看起来像这样。



这种方式测试过不行,


TextInputLayout TextInputEditText

更改材质TextInputLayout OutlinedBox散焦颜色

Android样式 - 主题叠加(theme overlay)
打造 Material 颜色主题 | 实现篇

android:textAlignment 参数解释

Android控件属性(2) - gravity、layout_gravity、textAlignment的区别

更改未聚焦的TextInputLayout的边框颜色或框描边

6.0新控件:TextInputLayout_TextInputEditText的使用

从登陆界面学习TextInputLayout

 private  String[] accounts = { "18236593333", "13463373657", "18235784765", "18234637686" };

        ArrayAdapter<String> arrayAdapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,accounts);
        mAccountView.setAdapter(arrayAdapter);//输入至少两个字符才会提示


android-光标下划线



Android Material 常用组件详解(二)—— TextInputLayout 使用详解


Android Material Design(一)史上最全的材料设计控件大全

Android Material 常用组件详解(五)—— MaterialButton、MaterialButtonToggleGroup、ShapeableImageView 使用详解

Android Material组件使用详解

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,470评论 6 501
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,393评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 162,577评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,176评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,189评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,155评论 1 299
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,041评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,903评论 0 274
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,319评论 1 310
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,539评论 2 332
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,703评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,417评论 5 343
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,013评论 3 325
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,664评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,818评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,711评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,601评论 2 353

推荐阅读更多精彩内容

  • 考虑如下几个问题:比如我想要预估一下某篇文章的访问量。那么我可能会搜罗一些数据来帮我分析: 文章id访问量点赞数收...
    夏普123阅读 1,569评论 0 1
  • 当工作文件和需求过多时,需要各种命令配合使用: 1.rm 删除不满足条件的文件 2.显示当前目录的绝对路径 3.查...
    溪溪溪溪溪川阅读 311评论 0 2
  • 目录 如何遍历数组 如何遍历对象 http浏览器缓存机制 304状态码 500状态码具体场景 DNS原理 CND原...
    Grandperhaps阅读 330评论 0 1
  • 前台需要展示图片,期望后台直接返回图片地址,但是后台给的是的文件流而不是一个图片地址,需要把文件流转为base64...
    宏_4491阅读 260评论 0 0
  • Android一天一题知识点https://www.jianshu.com/u/f9fbc7a39b36Andro...
    不好办啊呀阅读 225评论 0 0