Android 5.x常用控件(一)
来源:互联网 发布:rsync指定ssh端口 编辑:程序博客网 时间:2024/06/05 10:03
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" />
0 0
- Android 5.x常用控件(一)
- Android常用控件(一)
- Android常用控件(一)
- Android 常用控件一
- android常用控件总结(一)
- Android 常用控件(一)
- android 常用控件(一)
- Android常用控件一之文本控件
- Android常用复杂控件使用(一)--ViewPager
- android中常用的控件一TextView
- Android常用控件之ListView(一)
- android常用控件归类(一)
- Android—常用控件(一)文本控件
- Android 5.x(一) 新控件之RecyclerView,CardView,Palette的使用
- Android 5.x新增控件之-CardView
- MFC常用控件一
- OC常用控件一
- 4.常用控件(一)
- 下拉多选
- Linux常用命令
- 字符设备驱动第十九课---platform3
- 20161210计算机科学导论04_磁盘
- 折半查找算法
- Android 5.x常用控件(一)
- IM基础概念和原理
- ORACLE SQL 语句
- 行人检测综述
- php+nginx做下载服务器配置
- Using Dagger 2 for dependency injection in Android - Tutorial
- 【JVM】java 虚拟机--新生代与老年代GC
- Android 自绘TextView 解决提前换行,并配置结尾样式
- 计算机视觉入门之数学篇