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"));
    }
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/415711.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Arcgis10安装说明

1、 先安装dotnet framework 3.5 ,必须要装这个才能运行安装程序。 2、 接着安装Arcgis Desktop &#xff0c;只需下一步&#xff0c;下一步执行就好了。完成后&#xff0c;停掉服务。 3、 安装LicenseManager &#xff0c;下一步执行就可以。 4、 接着来破解&…

前端学习(2606):vue简单叙述

第一步 引入 第二步new Vue 第三步 data绑定数据

wux-button 样式扩展 增加shape属性

1、原来的写法和界面图如下 <wux-button block type"orange">拍照确认</wux-button>2、现在的写法只需要增加一个shape"round"参数&#xff0c;可以实现按钮边框为半圆 <wux-button block type"orange" shape"round"&g…

android webView注入js方法

需要在页面加载完成之后才能注入自定义js方法 webView.setWebViewClient(new WebViewClient() {Overridepublic boolean shouldOverrideUrlLoading(WebView view, String url) { // view.loadUrl(url);return true;//true时&#xff0c;不可点击跳页效果&…

前端框架Bootstrap简单介绍

下载&#xff1a; 解压之后&#xff1a; 把这些文件拷贝到项目中 页面使用时 只需要引入&#xff1a; 然后我们就可以参考官网来设计需要的前端页面了 设计一个按钮&#xff1a;button 只需要标明css样式中使用的类 下面就是现实效果&#xff1a; 转载于:https://www.cnblo…

CASS软件学习笔记

最近需要学习数据处理&#xff0c;用到的软件是Cass6.1 软件&#xff0c;下面我将学习中的笔记进行了整理。 1、Cass 6.1 支持是CAD2004 &#xff0d;2006&#xff0c;安装的话&#xff0c;先装CAD&#xff0c;然后破解&#xff0c;再装Cass &#xff0c;然后打上补丁&#xf…

vue学习中遇到的错误 Duplicate keys detected: ‘[object Object]‘. This may cause an update error.

前端入门自学&#xff0c;说错的请大神指点。 Avoid using non-primitive value as key, use string/number value instead. Duplicate keys detected: ‘[object Object]’. This may cause an update error.运行后出现这些警告&#xff0c;意思是检测到重复的键值。 把:key里…

mongoose 数据库设计千万要注意 Cast to [number] failed for value

不要定义字段type balance_flow: [{// 提现金额money: { type: Number },// 资金类型 0>提现 withdraw 1>资金流入 user_activetype: Number}],这样会报错

Linux Shell中有三种引号的用法

Linux Shell中有三种引号&#xff0c;分别为双引号&#xff08;" "&#xff09;、单引号( )以及反引号( )。 其中双引号对字符串中出现的$、、和\进行替换&#xff1b;单引号不进行替换&#xff0c;将字符串中所有字符作为普通字符输出&#xff0c;而反引号中字符串作…

工作113:添加echart折线图

<template><div><el-card><div slot"header" class"clearfix"><span>订单信息</span></div><!--样式控制全部 已经退回 待审核--><el-row><el-radio-group v-model"query.status" siz…

测试管理

测试管理工作检查表&#xff1a; 1. 检查每轮测试开始时测试环境是否准备好&#xff08;包括软件硬件、测试基本数据等&#xff09;&#xff1b; 2. 确保测试环境&#xff08;数据和程序&#xff09;与开发分离&#xff0c;除了测试组之外其他人不能更新测试环境的数据和程序…

android 获取webView高度,设置webView高度

1、注入获取webView高度的js方法 webView.setWebViewClient(new WebViewClient() {Overridepublic boolean shouldOverrideUrlLoading(WebView view, String url) { // view.loadUrl(url);return true;//true时&#xff0c;不可点击跳页效果&#xff0c;false时…

如何设计一个高并发系统

如何设计一个高并发系统&#xff1f; 如果你确实有真才实学&#xff0c;在互联网公司里&#xff0c;干过高并发系统&#xff0c;那你拿Offer&#xff0c;基本如探囊取物一样简单。 但你要真干过高并发系统&#xff0c;面试官绝对不会问这个问题&#xff0c;否则他就不太明智了…

李超线段树 [Heoi2013]Segment

问题 D: [Heoi2013]Segment 时间限制: 4 Sec 内存限制: 256 MB 题目描述 要求在平面直角坐标系下维护两个操作&#xff1a; 1.在平面上加入一条线段。记第i条被插入的线段的标号为i。 2.给定一个数k,询问与直线 x k相交的线段中&#xff0c;交点最靠上的线段的编号。 输…

Android 城市选择,热门城市,全部城市(美团、滴滴、淘宝)

demo链接&#xff1a;https://download.csdn.net/download/meixi_android/10819638 实现效果&#xff1a; 实现方法&#xff1a;非常简洁快速&#xff0c;三步集成实现地区选择器 1、导入city.module module导入方法&#xff1a;https://blog.csdn.net/meixi_android/articl…

虚拟化资料

很感谢 http://pan.baidu.com/netdisk/extractpublic?uk503876868#dir

汽车列表 车型选择 源码备忘

因为版权问题&#xff0c;选汽车的时候不能显示汽车自己真实的图片&#xff0c;下面我需要改成列表形式&#xff0c;下面记录一下代码 1、实现效果 2、源码 <div class"car-brand-list"><div v-for"(brand,index) in brandList" :key"inde…

Android View生命周期

View的关键生命周期为&#xff1a;> 构造View() --> onFinishInflate() --> onAttachedToWindow() --> onMeasure() --> onSizeChanged() --> onLayout() --> onDraw() --> onDetackedFromWindow()Creation&#xff08;创建&#xff09;Constructors&a…