直播平台源代码,收到新消息后,系统显示小红点提示

直播平台源代码,收到新消息后,系统显示小红点提示实现的相关代码

 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
 
    <CheckedTextView
        android:id="@+id/tv_tab_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        style="@style/MiddleTextStyle"
        android:text="我的回复"
        android:textColor="@color/selector_tab_text"/>
 
    <TextView
        android:id="@+id/tv_message_count"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="5dp"
        android:layout_alignBottom="@id/tv_tab_title"
        android:layout_toEndOf="@id/tv_tab_title"
        android:background="@drawable/shape_red_point"
        android:gravity="center"
        android:textColor="@color/white_color"
        android:textSize="@dimen/text_size_10"
        android:text="9"
        android:visibility="visible"/>
 
</RelativeLayout>

写好tab的布局之后,可以使用tabLayout.setCustomView(View v)自定义tab的样式,自定义tab的view之后,需要添加listener,自行修改选中和非选中状态,而不是直接setupWithViewPager了

 


       for (int i = 0; i < 2; i++) {
            TabLayout.Tab tab = tabLayout.newTab();
            tab.setCustomView(getTabView(i));
            tabLayout.addTab(tab);
        }
        tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                //自行修改选中状态
            }
 
            @Override
            public void onTabUnselected(TabLayout.Tab tab) {
               //自行修改非选中状态
            }
 
            @Override
            public void onTabReselected(TabLayout.Tab tab) {
 
            }
        });

 

以上就是直播平台源代码,收到新消息后,系统显示小红点提示实现的相关代码, 更多内容欢迎关注之后的文章

 

posted @ 2022-04-07 14:28  云豹科技-苏凌霄  阅读(72)  评论(0)    收藏  举报