日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

android 底部表格布局TableLayout

發布時間:2023/12/10 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。