Android TabLayout 宽度无法充满屏幕
Android TabLayout 宽度无法充满屏幕
我们在使用TabLayout的时候,很多时候都需要宽度充满屏幕,并且平分屏幕。类似于如下的效果:
但很多时候我们在使用了如下代码的时候发现TabLayout总是有一个默认的边距。
<com.google.android.material.tabs.TabLayoutandroid:id="@+id/menu_tab"android:layout_width="match_parent"android:layout_height="@dimen/dp_40"app:tabGravity="fill"app:tabIndicatorFullWidth="false"app:tabIndicatorHeight="0dp"app:tabMode="fixed"app:tabRippleColor="@android:color/transparent" />
没充满的效果:
其实TabLayout总是无法充满屏幕,是因为TabLayout设置了一个默认的边距,我们要想使之充满屏幕的宽度,只要去掉这个默认的边距即可。如下,添加app:tabPaddingStart=“0dp”,app:tabPaddingEnd="0dp"即可:
<com.google.android.material.tabs.TabLayoutandroid:id="@+id/menu_tab"android:layout_width="match_parent"android:layout_height="@dimen/dp_40"app:tabGravity="fill"app:tabIndicatorFullWidth="false"app:tabIndicatorHeight="0dp"app:tabMode="fixed"app:tabPaddingStart="0dp"app:tabPaddingEnd="0dp"app:tabRippleColor="@android:color/transparent" />
app:tabPaddingStart : 相当于 android:layout_marginLeft
app:tabPaddingEnd : 相当于 android:layout_marginRight
app:tabPaddingTop : 相当于 android:layout_marginTop
app:tabPaddingBottom:相当于 android:layout_marginBottom
Android TabLayout 宽度无法充满屏幕相关推荐
- ImageView宽度填满屏幕,高度自适应
原文链接:http://blog.csdn.net/easion_zms/article/details/50263409#comments 在CSS中轻松设置width=100%就可以使得图片宽度充 ...
- Android实践-自定义dialog从屏幕底部弹出并且充满屏幕宽度
转载出处http://blog.csdn.net/nugongahou110 通常我们使用dialog的时候会遇到一些问题,比如我想用自己定义的布局来替代系统那个黑乎乎的布局时我要怎么做?我想要指定d ...
- Android自定义dialog从屏幕底部弹出并且充满屏幕宽度
效果如下 1.首先我们先来定义一个dialog的布局 <?xml version="1.0" encoding="utf-8"?> <Line ...
- android 图片铺满imageview,简单实现ImageView宽度填满屏幕,高度自适应的两种方式...
两种方式 1.重写View的onMeasure方法 参考这里easion_zms的专栏 核心代码 protectedvoidonMeasure(intwidthMeasureSpec,intheigh ...
- DatagridView自动充满屏幕,并能指定某列宽度
1.要使datagridview正好充满屏幕,设置其AutoSizeColumnsMode属性为fill 2. 同时,我们想要某列宽点,某列窄点,在AutoSizeColumnsMode属性为fill ...
- 【android】两个按钮的宽度各占屏幕的一半
两个按钮的宽度各占屏幕的一半 <LinearLayout><Button android:layout_height="wrap_content"android: ...
- Android ScrollView充满屏幕
Android ScrollView充满屏幕 ScrollView充满屏幕 textAllCaps大小写 ScrollView充满屏幕 有时ScrollView的实际内容不够,又想让它充满屏幕. 如果 ...
- Android tabLayout+recyclerView实现锚点定位
原文链接:https://mp.weixin.qq.com/s/L3o2i3WTmg1ScXEYDS8YCg 在上一篇文章 [Android 实现锚点定位 ](https://mp.weixin.qq ...
- AppBarLayout中的Android TabLayout
In this tutorial, we'll discuss and implement Android TabLayout in our android application. Also we' ...
最新文章
- SAP WMSD集成之Copy WM Quantity – Copy WM qty as delivery qty into delivery
- jsp mysql驱动程序_JSP通过JDBC驱动MySQL数据库方法
- python游戏程序中游戏对象是什么_练习项目21:使用python制作游戏(下)
- python自动化测试——测试报告以附件形式发送邮件
- 如果年轻,就出发吧!
- glibc与MSVC CRT(转载)
- 95-40-060-java.util.concurrent-ConcurrentSkipListMap
- [导入]基于Spring+zk的WebDisk系统研究.pdf(462.84 KB)
- 用Google XML Sitemaps为你的网站创建Sitemap
- error 系统错误 错误码10007_工业界纠错系统
- Hibernate 学习的书-夏昕(1)
- air202-DTU接入ONENET平台简单教程
- MySQL:互联网公司常用分库分表方案汇总
- python编程else是什么意思_Python 中的 else详解
- nginx: [warn] conflicting server name locahost on 0.0.0.0:80, ignored
- mysql egt_ThinkPHP常用的运算符介绍eq|neq|gt|egt|lt|elt|heq|nheq
- html5超萌哈士奇,哈士奇,是一种让人又爱又恨,又拥有自己独特风格的雪橇犬...
- PPASR流式与非流式语音识别
- 【前端】javascript实现导航栏筋斗云效果特效
- 用Pandas秒秒钟搞定24张Excel报表,还做了波投放分析!
热门文章
- 学习笔记 Java_ch03_封装 2014.7.22
- Docker实践2:用Docker搭建hg-server
- 代理服务器与反向代理服务器的区别
- (六)音视频 MediaCodec使用遇到的问题
- 影像信息提取之——目视解译
- instr()字符查找函数
- Java+SSM会议室预约系统(含源码+论文+答辩PPT等)
- Rasa课程、Rasa培训、Rasa面试系列 金融银行案例Bot 多种状态转换-转账及信用卡支付
- 王蔷强势晋级澳网32强 平个人大满贯最佳战绩
- [AWT] 弹球小游戏(实现篇)