安卓:CollapsingToolbarLayout与搜索查看,文字重叠 [英] Android: CollapsingToolbarLayout and SearchView, text overlapping

查看:222
本文介绍了安卓:CollapsingToolbarLayout与搜索查看,文字重叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有个小问题与搜索查看文字重叠CollapsingToolbarLayout称号。当CollapsingToolbarLayout扩大,就没有问题:

I have little problem with overlapping CollapsingToolbarLayout title with SearchView text. When is CollapsingToolbarLayout expanded, there is no problem:

但是,当处于折叠状态,文字重叠:

But when is collapsed, the text is overlapped:

如何解决?

推荐答案

我试图由Tomas答案,但它有,一旦用户滚动,该appbar再次崩溃问题,该问题再次出现。

I tried the answer by Tomas, but it had a problem that as soon as the user scrolls, the appbar collapses again and the problem re-appears.

于是我想出了另一种解决方案是使倒塌标题文本透明的,当搜索查看扩展。这个工程很好,不依赖于或更改折叠/展开的appbar的状态。

So I came up with another solution which is to make the collapsed title text transparent when the searchview is expanded. This works nicely and does not depend on or change the collapse/expand state of the appbar.

简单:

    if (searchViewExpanding) {
        collapsingToolbarLayout.setCollapsedTitleTextColor(Color.TRANSPARENT);
    } else {
        collapsingToolbarLayout.setCollapsedTitleTextColor(Color.WHITE);
    }

当然,你需要处理 setOnActionExpandListener 您的搜索菜单项的知道什么时候调用此。

Of course, you'll need to handle setOnActionExpandListener of your search menu item to know when to call this.

这篇关于安卓:CollapsingToolbarLayout与搜索查看,文字重叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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