按住按钮会显示一个正在录音的动态窗口,自动识别音量
效果图
大部分逻辑写在自定义组件RecordButton.java 和 AmrPlayBto.java
xml简单引用即可
private AmrPlayBto mPlayButton;
private RecordButton mRecordButton;
mRecordButton.setOnFinishedRecordListener(new OnFinishedRecordListener() {
@Override
public void onFinishedRecord(String audioPath) {
if (audioPath != null) {
// Toast.makeText(context, "录音完成:" + audioPath,
// Toast.LENGTH_SHORT).show();
mPlayButton.setVisibility(View.VISIBLE);
...
} else {
mPlayButton.setVisibility(View.GONE);
...
}
}
});