TabLayout highlite和涟漪效果 [英] TabLayout highlite and Ripple effect

查看:140
本文介绍了TabLayout highlite和涟漪效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对TabLayout有两个疑问

I have two question with TabLayout

1)我可以删除TabLayout高亮显示或更改选项卡布局的突出显示颜色吗?

1)Can i remove TabLayout highlight or change highlight color of tab layout?

2)我可以为标签添加波纹效果吗?每个标签都包含TextView,我尝试添加类似这样的自定义背景

2)Can i add ripple effect for tab. Each tab contain TextView i try to add custom background something like this

<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="?android:colorControlHighlight">
    <item android:drawable="@drawable/btn_white_bg" />
</ripple>

但它不起作用.

推荐答案

另一个对我有用的解决方案

Another solution that works for me

<android.support.design.widget.TabLayout
    android:id="@+id/tab_layout"
    android:minHeight="?attr/actionBarSize"
    android:layout_width="match_parent"
    app:tabMode="fixed"
    app:tabGravity="fill"
    android:clipToPadding="false"
    android:elevation="0dp"
    style="@style/MyCustomTabLayout"
    android:background="@color/colorPrimary"
    app:tabBackground="?attr/selectableItemBackground"
    app:tabIndicatorColor="@color/app_yellow"
    app:tabIndicatorHeight="4dip"
    android:layout_height="wrap_content"/>

我刚刚添加了以下几行

android:background ="@ color/colorPrimary"

app:tabBackground =?attr/selectableItemBackground"

这篇关于TabLayout highlite和涟漪效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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