Design库-TabLayout
来源:互联网 发布:如何用u盘重装mac 编辑:程序博客网 时间:2024/06/06 01:58
方式一
xml
<android.support.design.widget.TabLayout android:id="@+id/tabLayout" android:layout_width="wrap_content" android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android"/>
代码中
tabLayout = (TabLayout)findViewById(R.id.tabLayout); tabLayout.addTab(tabLayout.newTab().setText("Tab 1")); tabLayout.addTab(tabLayout.newTab().setText("Tab 2")); tabLayout.addTab(tabLayout.newTab().setText("Tab 3"));
方式二
<android.support.design.widget.TabLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/tabLayout" android:layout_width="wrap_content" android:layout_height="wrap_content"> <android.support.design.widget.TabItem android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Tab1"/> <android.support.design.widget.TabItem android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Tab2"/> <android.support.design.widget.TabItem android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Tab3"/></android.support.design.widget.TabLayout>
改变TabLayout的颜色
改变选中字体的颜色
app:tabSelectedTextColor=”@android:color/holo_orange_light”
改变未选中字体的颜色
app:tabTextColor=”@color/colorPrimary”
改变指示器下标的颜色
app:tabIndicatorColor=”@android:color/holo_orange_light”
改变整个TabLayout的颜色
app:tabBackground=”xxx”
改变TabLayout内部字体大小
app:tabTextAppearance=”@android:style/TextAppearance.Holo.Large”
改变指示器下标的高度
app:tabIndicatorHeight=”4dp”
添加图标
tabLayout.addTab(tabLayout.newTab().setText(“Tab 1”).setIcon(R.mipmap.ic_launcher));
Tab的模式
app:tabMode=”scrollable”
可以滑动
加入Padding
设置Tab内部的子控件的Padding
app:tabPadding=”xxdp”
app:tabPaddingTop=”xxdp”
app:tabPaddingStart=”xxdp”
app:tabPaddingEnd=”xxdp”
app:tabPaddingBottom=”xxdp”
设置整个TabLayout的Padding:
app:paddingEnd=”xxdp”
app:paddingStart=”xxdp”
内容的显示模式
app:tabGravity=”center”
Tab的宽度限制
设置最大的tab宽度:
app:tabMaxWidth=”xxdp”
设置最小的tab宽度:
app:tabMinWidth=”xxdp”
Tab的“Margin”
TabLayout开始位置的偏移量:
app:tabContentStart=”100dp”
TabLayout的监听事件
tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { @Override public void onTabSelected(TabLayout.Tab tab) { } @Override public void onTabUnselected(TabLayout.Tab tab) { } @Override public void onTabReselected(TabLayout.Tab tab) { } });
和ViewPager的联动
tabLayout.setupWithViewPager(Viewpager);
默认选中某项
tablayout.getTabAt(position).select();
- Design库-TabLayout
- Design库-TabLayout属性详解
- Design库-TabLayout属性详解
- Design库-TabLayout属性详解
- Design库-TabLayout属性详解
- Design库-TabLayout属性详解
- Design库-TabLayout的使用
- Design库-TabLayout属性详解
- Design库-TabLayout属性详解
- Design库-TabLayout属性详解
- Design库-TabLayout属性详解
- Design库-TabLayout属性详解
- Design库-TabLayout属性详解
- Design库-TabLayout属性详解
- android design库之TabLayout的用法
- Android Support Design库之TabLayout
- Design库中的TabLayout的使用
- Android中Design库之TabLayout
- app与后台的token、sessionId、RSA加密登录认证与安全解决方案
- Unicode 和 UTF-8 有何区别?
- VS 无法嵌入互操作类型“Microsoft.Office.Interop.xxx.ApplicationClass” 请改用适用的接口
- SVM推导
- 50. Pow(x, n)
- Design库-TabLayout
- Mycat中Buffer机制分析—HeapByteBuffer与DirectByteBuffer
- Linux下的 压缩 解压缩 命令详解
- POJ Expanding Rods <简单二分>
- Spring MVC源码分析—网站架构及其演变过程
- redis的定义-form wiki
- Spring Cache使用参考指南
- TCP Nagle算法&&延迟确认机制
- hadoop运行wordcount实例