VerticalTablayout—豎的tab欄

效果圖

image

1.添加依賴

    //垂直的tablayout
    implementation 'q.rorbin:VerticalTabLayout:1.2.5'

2.xml文件中添加控件【VerticalTabLayout集合幀布局使用,fragment開啟事物的方法,或者直接用豎著的ViewPager

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    tools:context=".ui.country.fragment.InternationalFragment">

    <q.rorbin.verticaltablayout.VerticalTabLayout
        android:id="@+id/tab"
        android:layout_width="@dimen/dp_100"
        android:layout_height="match_parent"
        android:background="@color/c_EAEAEA"
        app:indicator_width="@dimen/dp_2"
        app:tab_height="@dimen/dp_50"
        app:tab_mode="scrollable" />

    <FrameLayout
        android:id="@+id/fl_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</LinearLayout>

3.代碼簡單使用

            mTab.setTabAdapter(new TabAdapter() {
            //設置個數(shù)
            @Override
            public int getCount() {
                return list.size();
            }

            @Override
            public ITabView.TabBadge getBadge(int position) {
                return null;
            }

            @Override
            public ITabView.TabIcon getIcon(int position) {
                return null;
            }
            //給tab欄設置標題
            @Override
            public ITabView.TabTitle getTitle(int position) {
                ITabView.TabTitle title = new ITabView.TabTitle.Builder()
                        .setContent(list.get(position).getName())
                        .setTextColor(Color.RED,Color.BLACK)
                        .build();
                return title;
            }
          //設置背景
            @Override
            public int getBackground(int position) {
                return 0;
            }
        });

  1. 屬性說明
    app:indicator_color 指示器顏色
    app:indicator_width 指示器寬度
    app:indicator_gravity 指示器位置
    app:indicator_corners 指示器圓角
    app:tab_mode Tab高度模式
    app:tab_height Tab高度
    app:tab_margin Tab間距
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容