Animation switching between voice input and text input

Source: Internet
Author: User

With the rapid popularization of speech, many applications have begun to increase the voice input function. Below is a simple animation switching between voice and text input:

Layout file:

<Viewflipper Android: Id = "@ + ID/viewflipper1" Android: layout_width = "fill_parent" Android: layout_height = "wrap_content" Android: layout_alignparentbottom = "true"> <linearlayout android: id = "@ + ID/layout01" Android: layout_width = "fill_parent" Android: layout_height = "wrap_content"> <button Android: Id = "@ + ID/BT" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: layout_weight = "1" Android: text = "button"/> <imageview Android: id = "@ + ID/image01" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: src = "@ Android: drawable/ic_btn_speak_now "/>" </linearlayout> <linearlayout Android: Id = "@ + ID/layout02" Android: layout_width = "fill_parent" Android: layout_height = "wrap_content" android: visibility = "gone"> <edittext Android: Id = "@ + ID/TV" Android: layout_width = "fill_parent" Android: layout_height = "wrap_content" Android: layout_weight = "1"/> <imageview Android: Id = "@ + ID/image02" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: src = "@ Android: drawable/ic_dialog_dialer" Android: text = "Search"/> </linearlayout> </viewflipper>
Viewflipper has many introductions on the Internet

Logical implementation:

Viewflipper = (viewflipper) findviewbyid (R. id. viewflipper1); image01 = (imageview) findviewbyid (R. id. image01); image02 = (imageview) findviewbyid (R. id. image02); leftinanimation = animationutils. loadanimation (this, R. anim. left_in); leftoutanimation = animationutils. loadanimation (this, R. anim. left_out); image01.setonclicklistener (New onclicklistener () {@ overridepublic void onclick (view v) {viewflipper. setinanimation (leftinanimation); viewflipper. setoutanimation (leftoutanimation); viewflipper. shownext (); // slide to the right}); image02.setonclicklistener (New onclicklistener () {@ overridepublic void onclick (view v) {viewflipper. setinanimation (leftinanimation); viewflipper. setoutanimation (leftoutanimation); viewflipper. shownext (); // slide to the right }});
Here we only provide some ideas. In fact, we can also use ongesturelistener for gesture slide operations.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.