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"/> < ; 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