Android 5.x常用控件(一)
2016-12-09 15:27
357 查看
FloatingActionButton
这是一个浮动按钮。由于FloatingActionButton是重写ImageView的,所有FloatingActionButton拥有ImageView的一切属性简单使用
compile 'com.android.support:design:25.0.0'
<android.support.design.widget.FloatingActionButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_discuss" app:fabSize="mini" />
app:fabSize :FloatingActionButton的大小,有两种赋值分别是 “mini” 和 “normal”,默认是“normal”
app:backgroundTint:FloatingActionButton的背景颜色 默认取默认的颜色取的是,theme中的colorAccent
app:elevation=”Xdp”//显示的阴影大小
app:pressedTranslationZ=”12dp”//点击时的阴影大小
TextInputLayout
TextInputLayout继承自LinearLayout。一般将EditText和它的子类包含在内,以便用户在输入文本时,且当提示文本被隐藏时显示一个浮动的标签。也支持通过setErrorEnabled(boolean)和setError(CharSequence)方法来显示错误提示。
<android.support.design.widget.TextInputLayout android:id="@+id/textInputLayoutName" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" > <EditText android:id="@+id/editTextName" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/hint_name" android:textColorHint="@color/colorGray" /> </android.support.design.widget.TextInputLayout>
监听编辑框的变化
editQuery.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) { } @Override public void afterTextChanged(Editable s) { } });
常用设置
setHint():设置提示语。
getEditText():得到TextInputLayout中的EditView控件。
setErrorEnabled():设置是否可以显示错误信息。
setError():设置当用户输入错误时弹出的错误信息。
TabLayout
Tabs选项卡<android.support.design.widget.TabLayout android:id="@+id/tabs" <!--Tab被选中字体的颜色--> app:tabSelectedTextColor="@android:color/holo_blue_bright" <!--Tab未被选中字体的颜色--> app:tabTextColor="@android:color/black" <!--Tab指示器下标的颜色--> app:tabIndicatorColor="@android:color/holo_blue_bright" android:layout_width="match_parent" android:layout_height="wrap_content" />
相关文章推荐
- androidUI第六部分---其他常用控件举例
- Android学习第三天:页面布局和常用控件
- android的常用控件总结【安卓入门五】
- Android常用布局控件之RelativeLayout
- android常用控件四 GridView
- Android常用控件的信息!
- android 事件 和 常用控件
- Android常用控件-AutoCompleteTextView
- Android常用控件-spinner
- android常用控件(转)
- Android常用控件的基本使用说明
- Android基础(四) 常用控件
- Android学习笔记--Android开发时常用控件(三)
- Android常用控件-DatePicker以及对话框的两种使用方法
- android常用控件(三)- ProgressBar、ListView
- Android学习第二天:Intent传输数据、常用控件和Activity生命周期
- Android开发笔记--Android开发时常用控件(二)
- Android基础(四) 常用控件 - ProgressBar
- android常用控件二 gallery
- Android的一段常用动画效果代码(如何让点击的图片控件加速飞入到指定位置)