android studio 30天学习笔记-day 17-TabLayout+TabItem

TabLayout提供了一个水平的布局方式显示,TabItem是TabLayout显示的物件。

dependencies

    implementation 'com.google.android.material:material:1.1.0'

在activity_main4修改

新增TabLayout

<com.google.android.material.tabs.TabLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/tablayout"
            app:tabRippleColor="@color/colorAccent"
            app:tabIndicatorColor="@color/colorPrimary">
            ...
            </com.google.android.material.tabs.TabLayout>

app:tabRippleColor=tabItem点下去会呈现扩散的颜色
app:tabIndicatorColor=tabItem下方指示条的颜色
tabTextColor=tab字体的颜色

  • app:tabMode=有以下2种模式
    1.scrollable:当Tab过多无法显示在画面中时,可以左右滚动看其他的Tab。
    2.fixed:将所以Tab都塞到画面中。

新增TabItem

TabItem是TabLayout里可以点选的物件

<com.google.android.material.tabs.TabItem
           android:layout_width="match_parent"
           android:layout_height="match_parent"
           android:text="显示"/>
<com.google.android.material.tabs.TabItem
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:text="新增"/>
<com.google.android.material.tabs.TabItem
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:text="修改"/>

成果:
https://ithelp.ithome.com.tw/upload/images/20210825/201389666fRRVDQCpN.jpg

明天会加上viewPager。


<<:  C# 鸡础观念- 目录

>>:  Day 20 : 线性回归与罗吉斯回归

VMware Horizon Client, Compose Server, Horizon Server 每周固定时段异常无法连线 !

状况描述: esxi server 7.0.0 上面运行 vSphere Client 7.0.0 ...

javascript变数与运算子3

接下来介绍比较运算值,也是用程序码跟注解来呈现 结果会以布林true跟false显示 ...

ESP32_DAY11 短路

究竟是谁有问题呢? 答案是... ... ... 最右边的这组电路有问题! 它的问题是这颗电阻根本没...

Flutter学习Day2 Widget 观念 StatelessWidget (上)

介绍 只要把Widget想像成一块块的乐高积木或是部件, 当你要建造一台新阿姆斯特朗旋风喷射阿姆斯特...

让 GitHub Action 帮你天天登入 iThelp 赚取登入点数

前言 这是个人很久以前在闲暇之余写的一个专案,技术多为爬虫观念,後来整合 GitHub Action...