Android client voice mobile interface example code

Today, I'd like to introduce the implementation of the voice mobile interface. You should have seen the new version of the client. Here I just briefly introduce the control layout. You can see the complete source code of this control here: http://git.oschina.net/oschina/android-app/blob/master/osc-android-app/src/net/oschina/app/widget/RecordButton.java

First of all, the overall interface is divided into three parts. I believe you can see it without me.

The middle part is the text moving part. The main body is an EditText with padding (margin) set. Below the EditText is a description of the number of remaining input words. In fact, there is also an ImageView for displaying the recording icon on the left of "you can also enter XX words"

The bottom layer is the implementation of the recording custom control mainly explained in this paper.

The following whole block is an area of custom controls. I named it recordbutton, which is a ViewGroup inherited from relativelayout.

It includes three imageviews on the left, middle and right: audition and deletion, and the recording button in the middle.

There is a textview for prompt at the top and bottom of the recording button.

The overall layout can be loaded by calling view. Inflator (CXT, r.layout.xxx, null); That's it.

As mentioned in the previous article, as the control logic of the control interface, we mainly look at the ontouchevent method: initialize the recorder when the finger is pressed. When the finger moves on the screen and slides over the button, event.gety will return a negative value (because it slides out of the control). Here I write - 50, mainly to buffer more and prevent misoperation.

Let's look at the code first

The recording related tools are the same as before, which is the advantage of separating functions from views. You can use them at any time by copying and pasting them at any time.

If you are careful, you will find that the left and right circular buttons will zoom in as your fingers move to the top. In fact, this is also the effect of animating the two circular buttons by listening to the ontouch event. The harmony belt is the following sentence. (Note: setscale X and setscale y methods can only be called in api10, that is, versions above 3.0):

Summary @ h_ 403_ 46@

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>