Android Tablayout属性介绍
1.添加依赖
compile 'com.android.support:design:26.0.0-alpha1'
2.属性
改变选中字体的颜色
app:tabSelectedTextColor="@android:color/holo_orange_light"
改变未选中字体的颜色
app:tabTextColor="@color/colorPrimary"
改变指示器下标的颜色
app:tabIndicatorColor="@android:color/holo_orange_light"
改变整个TabLayout的颜色
app:tabBackground="color"
改变TabLayout内部字体大小:
总觉得这个字体有点小了,于是想找方法把这个字变得大一点,
好像没有直接变大的方法,可是找到了这个:
app:tabTextAppearance="@android:style/TextAppearance.Holo.Large"//设置文字的外貌
改变指示器下标的高度
app:tabIndicatorHeight="4dp" 设置为0表示没有小标
添加图标(两种方法)
1.代码中
tabLayout.addTab(tabLayout.newTab().setText("Tab 1").setIcon(R.mipmap.ic_launcher));
2.xml文件zhong
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="tab1"
android:icon="@mipmap/ic_launcher_round"
/>好像不能设置图标和文字之间的距离
Tab的模式
app:tabMode="scrollable"//可滑动
app:tabMode="fixed"//固定的 不能滑动
加入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"//居中,如果是fill,则是充满
Tab的宽度限制
app:tabMaxWidth="xxdp"
app:tabMinWidth="xxdp"
Tab的“Margin”
app:tabContentStart="100dp"
TabLayout的监听事件
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) { } @Override
public void onTabUnselected(TabLayout.Tab tab) { } @Override
public void onTabReselected(TabLayout.Tab tab) { }
});
Android Tablayout属性介绍的更多相关文章
- Android TabLayout 在宽屏幕上tab不能平均分配的问题解决
当TabLayout 在宽屏幕的设备上,如平板横屏的时候,tab的宽度超过一定值后,就不在平均分配宽度,而是居中显示.此时设置 app:tabMode="fixed"或者 top_ ...
- android TabLayout实现京东详情效果
Google在2015的IO大会上,给我们带来了更加详细的Material Design设计规范,同时,也给我们带来了全新的Android Design Support Library,在这个supp ...
- [Android] TabLayout设置下划线(Indicator)宽度
在使用TabLayout的过程中,为每个标签添加一个 下划线,但发现每个下划线的 宽度 都是一样的,例如会如下显示 这样很难看,所以必须进行调整后的效果如下: 看,这样不是非常和谐啦!~~ 实现方法很 ...
- android TabLayout设置选中标签字体加粗功能
实现 TabLayout 选中tab标签字体加粗功能如下: xml文件中定义: <android.support.design.widget.TabLayout android:id=" ...
- Android tabLayout+recyclerView实现锚点定位
原文链接:https://mp.weixin.qq.com/s/L3o2i3WTmg1ScXEYDS8YCg 在上一篇文章 Android 实现锚点定位中,我们介绍了tablayout+scrollV ...
- 011 Android TabLayout+ViewPager实现顶部滑动效果(多个页面)
1.TabLayout介绍 TabLayout提供了一个水平的布局用来展示Tabs,很多应用都有这样的设计,典型的有网易新闻,简书,知乎等.TabLayout就可以很好的完成这一职责,首先TabLay ...
- Android TabLayout+ViewPager禁止滑动
1.重写ViewPager并重写覆盖ViewPager的onInterceptTouchEvent(MotionEvent arg0)方法和onTouchEvent(MotionEvent arg0) ...
- android ——Tablayout
Tabs make it easy to explore and switch between different views. 通过TabLayout可以在一个活动中通过滑动或者点击切换到不同的页面 ...
- android TabLayout设置选项卡之间的距离无效已解决
根据下面的链接设置完距离后无法生效 https://www.jb51.net/article/131304.htm layout <com.google.android.material.tab ...
随机推荐
- 从JVM的角度解析String
1. 字符串生成过程 我们都知道String s = "hello java";会将“hello java”放入字符串常量池,但是从jvm的角度来看字符串和三个常量池有关,clas ...
- Data_Structure-绪论作业
一.作业题目 仿照三元组或复数的抽象数据类型写出有理数抽象数据类型的描述 (有理数是其分子.分母均为整数且分母不为零的分数). 有理数基本运算: 构造有理数T,元素e1,e2分别被赋以分子.分母值 销 ...
- Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?
python3.6.3 我在处理爬虫时候使用BeautifulSoup中遇到报错 “ bs4.FeatureNotFound: Couldn't find a tree builder with t ...
- PHP定时任务Crontab结合CLI模式详解
从版本 4.3.0 开始,PHP 提供了一种新类型的 CLI SAPI(Server Application Programming Interface,服务端应用编程端口)支持,名为 CLI,意为 ...
- SQL2008R转SQL2005
1.SQL2008R生成 任务--生成脚本 “为服务器版本编写脚本”:SQL Server 2005 “要编写脚本的数据类型”:架构和数据 2.SQL2005还原超大sql语句文件 运行-cmd: o ...
- MFC 控件使用汇总
一.动态创建button CButton *button=new CButton; button->Create(_T(,,,),);//最后一个是ID BEGIN_MESSAGE_MAP(CM ...
- Mycat实战之数据迁移(oracle -- mysql)
1.案例场景: Mycat 后面接一个 Oracle 实例与一个 MySQL 实例,假设用户表,订单表,转账记录表, Oracle 字符集为 GBK 的,MySQL 字符集则要求 UTF8的 完成用户 ...
- C#使用ADO操作Excel
1 说明 把excel当成一个数据库,类似于Access数据库来操作. 2 源代码 2.1 Model层 /// <summary> /// 人员信息 /// </summary&g ...
- UIRect中的Anchor组件
[UIRect中的Anchor组件] Anchor用于实现粘着功能,寄存于UIRect类中.Anchor的类型有三种: 1.None:不使用跟随功能. 2.Unified:四条边使用相同的Target ...
- MobileSubstrate
[MobileSubstrate] Cydia Substrate (formerly called MobileSubstrate) is the de facto framework that a ...