首页 > 其他 > 详细

MD新控件笔记

时间:2016-05-29 21:23:59      阅读:226      评论:0      收藏:0      [点我收藏+]

FloatingActionButton

由于FloatingActionButton是重写ImageView的,所有FloatingActionButton拥有ImageView的一切属性.

控制FloatingActionButton的大小,背景颜色,阴影的深度等:

  1. app:fabSize 有两种赋值分别是 “mini” 和 “normal”,默认是“normal”.
  2. app:backgroundTint 默认的背景颜色是Theme主题中的
  3. app:elevation 阴影面积,dp为单位,越大阴影面积越大

注意:不能通过 android:background 属性来改变背景颜色,只能通过app:backgroundTint,因为FAB是继承自ImageView的。

TextInputLayout

里面需要放一个EidtText

<android.support.design.widget.TextInputLayout
        android:id="@+id/textInput"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>
    </android.support.design.widget.TextInputLayout>

 

final TextInputLayout  inputLayout = findView(R.id.textInput);
        inputLayout.setHint("input:");
        EditText editText = inputLayout.getEditText();
        editText.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                if (s.length()>4){
                    inputLayout.setErrorEnabled(true);//设置是否显示错误信息
                    inputLayout.setError("error text");
                }else{
                    inputLayout.setErrorEnabled(false);
                }
            }

            @Override
            public void afterTextChanged(Editable s) {
            }
        });

这个不知道为什么,我这的错误信息只会显示一次,删掉,重新写就不会出现了,OTZ……<待解决……

 

MD新控件笔记

原文:http://www.cnblogs.com/i-love-kobe/p/5540393.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!