android 底部表格布局TableLayout

《Android学习笔记总结+最新移动架构视频+大厂安卓面试真题+项目实战源码讲义》

完整开源地址:https://docs.qq.com/doc/DSkNLaERkbnFoS0ZF

          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"/>

  



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

  • 4
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值