Animated voice input and text input switches

Source: Internet
Author: User

With the rapid popularity of speeches, many applications are beginning to add voice input. Here is a simple animation switch for speech and text input:

Layout file:

<viewflipper android:id= "@+id/viewflipper1" android:layout_width= "Fill_parent" Android:layout_heig ht= "Wrap_content" android:layout_alignparentbottom= "true" > <linearlayout android:id= "@+id/ layout01 "android:layout_width=" fill_parent "android:layout_height=" wrap_content "> &L T Button android:id= "@+id/bt" android:layout_width= "Wrap_content" android:layou t_height= "Wrap_content" android:layout_weight= "1" android:text= "button"/> &lt ; ImageView android:id= "@+id/image01" android:layout_width= "Wrap_content" Android                    oid:layout_height= "Wrap_content" android:src= "@android:d rawable/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= "@andr Oid:drawable/ic_dialog_dialer "android:text=" Search/> </LinearLayout> </ViewFlipper>
Viewflipper Online has a lot of introduction

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 ();//Swipe Right}}); Image02.setonclicklistener (new Onclicklistener () {@Overridepublic void OnClick (View v) {viewflipper.setinanimation (leftinanimation); Viewflipper.setoutanimation (leftoutanimation); Viewflipper.shownext ();//Swipe Right}});
It's just a little bit of thinking, and it's actually enough.Ongesturelistener gesture swipe operation execution.

Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.

Animated voice input and text input switches

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.