android 底部表格布局TableLayout
添加依赖
compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.1.2@aar'
置于底部布局(最外层必须是RelativeLayout)
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tl="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:id="@+id/lyMeun" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:elevation="2dp" android:orientation="horizontal" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true"> <com.flyco.tablayout.CommonTabLayout android:id="@+id/t2_1" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/t2_1_background" android:paddingBottom="5dp" android:paddingTop="5dp" tl:tl_indicator_color="@color/t2_1_tl_indicator_color" tl:tl_textSelectColor="@color/t2_1_tl_textSelectColor" tl:tl_textUnselectColor="@color/t2_1_tl_textUnselectColor" tl:tl_underline_color="@color/t2_1_tl_underline_color" tl:tl_underline_height="1dp"/> </LinearLayout> </RelativeLayout>
java 代码
private String[] mTitles = {"首页", "消息", "联系人", "更多"}; private int[] mIconUnselectIds = {R.mipmap.tab_home_unselect, R.mipmap.tab_speech_unselect, R.mipmap.tab_contact_unselect, R.mipmap.tab_more_unselect}; private int[] mIconSelectIds = {R.mipmap.tab_home_select, R.mipmap.tab_speech_select, R.mipmap.tab_contact_select, R.mipmap.tab_more_select}; private ArrayList<CustomTabEntity> mTabEntities = new ArrayList<>(); private CommonTabLayout mTabLayout_1;
for (int i = 0; i < mTitles.length; i++) {mTabEntities.add(new TabEntity(mTitles[i], mIconSelectIds[i], mIconUnselectIds[i])); }
mTabLayout_1.setTabData(mTabEntities); mTabLayout_1.setOnTabSelectListener(new OnTabSelectListener() {@Override public void onTabSelect(int position) {Log.i("lgqq","body=====接受到推送下来的消息=1111111111111"+position);//底部item事件 }@Override public void onTabReselect(int position) {} });
TabEntity类
public class TabEntity implements CustomTabEntity {public String title; public int selectedIcon; public int unSelectedIcon; public TabEntity(String title, int selectedIcon, int unSelectedIcon) {this.title = title; this.selectedIcon = selectedIcon; this.unSelectedIcon = unSelectedIcon; }@Override public String getTabTitle() {return title; }@Override public int getTabSelectedIcon() {return selectedIcon; }@Override public int getTabUnselectedIcon() {return unSelectedIcon; } }
显示未读消息或显示未读红点
//显示未读红点 mTabLayout_1.showDot(2); MsgView rtv_1_2 = mTabLayout_1.getMsgView(2); if (rtv_1_2 != null) {if (rtv_1_2 instanceof SkinMsgView) {((SkinMsgView) rtv_1_2).setBackgroundColorResource(R.color.msg_background_color); } } mTabLayout_3.showDot(1); MsgView rtv_3_1 = mTabLayout_3.getMsgView(1); if (rtv_3_1 != null) {if (rtv_3_1 instanceof SkinMsgView) {((SkinMsgView) rtv_3_1).setBackgroundColorResource(R.color.msg_background_color); } } mTabLayout_4.showDot(1); MsgView rtv_4_1 = mTabLayout_4.getMsgView(1); if (rtv_4_1 != null) {if (rtv_4_1 instanceof SkinMsgView) {((SkinMsgView) rtv_4_1).setBackgroundColorResource(R.color.msg_background_color); } }//两位数 mTabLayout_2.showMsg(0, 55); MsgView rtv_2_0 = mTabLayout_2.getMsgView(0); if (rtv_2_0 != null) {if (rtv_2_0 instanceof SkinMsgView) {((SkinMsgView) rtv_2_0).setBackgroundColorResource(R.color.msg_background_color); } } mTabLayout_2.setMsgMargin(0, -5, 5); //三位数 mTabLayout_2.showMsg(1, 66); MsgView rtv_2_1 = mTabLayout_2.getMsgView(1); if (rtv_2_1 != null) {if (rtv_2_1 instanceof SkinMsgView) {((SkinMsgView) rtv_2_1).setBackgroundColorResource(R.color.msg_background_color); } } mTabLayout_2.setMsgMargin(1, -5, 5); //设置未读消息红点 mTabLayout_2.showDot(2); MsgView rtv_2_2 = mTabLayout_2.getMsgView(2); if (rtv_2_2 != null) {UnreadMsgUtils.setSize(rtv_2_2, dp2px(7.5f)); ((SkinMsgView) rtv_2_2).setBackgroundColorResource(R.color.t2_2_background); }//设置未读消息背景 mTabLayout_2.showMsg(3, 5); mTabLayout_2.setMsgMargin(3, 0, 5); MsgView rtv_2_3 = mTabLayout_2.getMsgView(3); if (rtv_2_3 != null) {if (rtv_2_3 instanceof SkinMsgView) {((SkinMsgView) rtv_2_3).setBackgroundColorResource(R.color.t2_2_background); ((SkinMsgView) rtv_2_3).setTextColor(getResources().getColor(R.color.t2_2_background)); ((SkinMsgView) rtv_2_3).setStrokeColorResource(R.color.t2_2_background); } else {rtv_2_3.setBackgroundColor(Color.parseColor("#6D8FB0")); } }
android 底部表格布局TableLayout相关推荐
- android 动态生成tablelayout,Android 表格布局TableLayout示例详解
一.表格布局 TableLayout 表格布局TableLayout以行列的形式管理子元素,每一行是一个TableRow布局对象,当然也可以是普通的View对象,TableRow离每放一个元素就是一列 ...
- 【Android开发学习24】界面布局之表格布局TableLayout+TableRow
一.基础知识: TableLayout置底,TableRow在TableLayout的上面,而Button.TextView等控件就在TableRow之上, 另外,TableLayout之上也可以单独 ...
- 表格布局(TableLayout)及重要属性
TableLayout属性: android:collapseColumns:将TableLayout里面指定的列隐藏,若有多列需要隐藏,请用逗号将需要隐藏的列序号隔开. androi ...
- 9 表格布局——TableLayout
学完了 Android 两个经典布局,是不是觉得已经可以应对大多数场景了?我记得当我学完 LinearLayout 和 RelativeLayout 之后,我觉得 UI 布局已经可以出师了,在本人从事 ...
- [Android] 底部菜单布局+PopupWindows实现弹出菜单功能(初级篇)
这篇文章主要是自己研究如何对底部菜单进行布局,并简单的实现点击不同"按钮"实现图片切换和背景切换的功能,最后通过PopupWindows实现弹出菜单,点击不同按钮能实现不同 ...
- Android用表格布局做菜单栏,Android开发菜单布局之表格布局示例
本文实例讲述了android开发菜单布局之表格布局.分享给大家供大家参考,具体如下: 多用于静态菜单页面 xml代码 代码内带详细解释 xmlns:android="http://schem ...
- 鸿蒙开发之表格布局(TableLayout)
一.描述 表格布局可以实现行列式摆放组件 , 也就是说可以把组件放在不同的单元格内进行布局呈现 . 它既可以通过xml代码实现也可以通过java代码实现 , 我们这里主要介绍xml实现方式. 二.表格 ...
- android标签栏图标大小,如何在android底部导航布局中增加图标大小?
我在 Android中使用最近由设计库25中的谷歌引入的底部布局导航样式.在我看到的所有教程和问题中,图标中的图像是正常大小,但是我的图像非常小,尽管事实上我保存到drawable文件夹的图像是72× ...
- 表格布局(tablelayout)
最新文章
- Excel VBA林木冠幅、分枝胸径字符串的拆解
- IDEA创建springboot项目:Unable to import maven project: See logs for details
- mysql sql执行加载顺序
- Eclipse debug Source not found
- C#中用WebClient.UploadData 方法上载文件数据
- 1984. 学生分数的最小差值
- 神啊,6小时30分钟,完成想要的所有Lync测试
- 工作流学习——Activiti流程实例、任务管理四步曲 (zhuan)
- 【sketchup 2021】草图大师的高级工具使用3【复杂贴图制作实例(山体和球面贴图、全景天空绘制、吊顶添加光带)、图层(标记)工具使用、视图与样式工具的常规使用与高级使用说明】
- 计算机答辩ppt结论,论文总结与致谢ppt_ppt结束致谢_答辩ppt致谢
- mac空格键跟删除键失灵
- blowfish算法c语言,使用Blowfish算法给文件加密
- 贴片钽电容的正负极性识别和贴片玻璃二极管的正负极性识别
- 如何使用Python打开一个TXT文件
- 嵌入式系统通信库设计
- ClickHouse MergeTree表引擎和建表语句
- 其实软件测试工程师也是程序员,很多人不知道
- 安卓进不去系统如何备份数据
- 九度OJ-1185:特殊排序
- cent os7 firefox插件崩溃(flash插件)
热门文章
- [css] 你知道css的预处理器和后处理器都有哪些吗?它们有什么区别呢?
- [css] 为什么float会导致父元素塌陷
- [js] for in 和 for of 的区别?
- 工作195:解决key值不唯一的报错
- 前端学习(2569):如何跨组件调用实例
- 前端学习(1366):express入门
- spring学习(29):xml配置规范
- 第六十一期: 从7600万个5G连接中,我们发现了7种最有前景的5G物联网应用
- ETH—Lwip以太网通信
- linux 查当前pid_杀死僵尸进程,你需要这些神奇高效的Linux命令行