调整Tablayout标题文本和图标之间的高度 [英] Adjust height between Tablayout title text and icon

查看:186
本文介绍了调整Tablayout标题文本和图标之间的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有任何方法可以缩短标题文本和 TabLayout 图标之间的距离,就像在Google加上图标和文本标题之间至少没有距离的地方一样.我已经搜索过,但直到现在都找不到.

I there any way to reduce the distance between the title text and the icon of TabLayout like in Google plus where the icons and text title have at least no distance. I have searched , but couldn't find anyway till now.

已编辑

这是我设置图标和标题的方式:

This is how I am setting icon and title:

 tabLayout.getTabAt(3).setIcon(R.drawable.ic_more_horiz_white_24dp);
 tabLayout.getTabAt(3).setText("More");

这是我的 TabLayout :

<android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:tabIndicatorColor="@color/white"
        app:tabIndicatorHeight="2dp"
        app:tabTextAppearance="?android:attr/textAppearanceSmall"
        />

推荐答案

您可以尝试使用此代码,它对我有用

you can try this code, it works for me

for (i in 0 .. tabLayout.tabCount) {
        val params = tabLayout.getTabAt(i)?.view?.getChildAt(0)?.layoutParams as LinearLayout.LayoutParams?
        params?.bottomMargin = 0
        tabLayout.getTabAt(i)?.view?.getChildAt(0)?.layoutParams = params
    }

这篇关于调整Tablayout标题文本和图标之间的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆