搜索editText动画(例如Chrome应用) [英] Search editText animation like Chrome app

查看:111
本文介绍了搜索editText动画(例如Chrome应用)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在屏幕中间进行搜索editText

I'm trying to make a search editText in the middle of screen,

只要按下该按钮,动画就会移动到工具栏中的searchView.

That whenever pressed, move with animation to the searchView in the toolbar.

与您在适用于Android的chrome应用(v46)的新标签中完全一样.

Exactly as you can find in new tab of chrome app (v46) for android.

找不到任何Github示例,所以知道如何实现吗?

Didn't find any Github example, so any idea how to implement that?

推荐答案

我创建了要点以显示实现此目的的一种方法: https://github.com/orenothnay/SearchBar

I've created a gist to show one way that this can be done: https://github.com/orenothnay/SearchBar

主要组件是FocusableEditText(我从android的searchview小部件改编而成).一旦用户移开键盘,它使用一种变通方法来使编辑文本失去焦点.然后您只需收听焦点更改事件并相应地更改UI.

The main component is FocusableEditText (which I adapted from androids searchview widget). It uses a workaround to allow the edit text to lose focus once the user removes the keyboard. and then you just listen to the focus change event and change your UI accordingly.

需要注意的是:必须将其包裹在窃取ViewGroup的焦点中,并且必须被告知清除对暂停的关注(否则键盘保持不动).

The caveates are: It must be wrapped in a focus stealing ViewGroup, and must be told to clear focus on pause (else the keyboard stays up).

这篇关于搜索editText动画(例如Chrome应用)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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