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.