就像在 whatsapp 中一样,我需要一个重新编码按钮和一个幻灯片来取消和淡入淡出动画,我搜索了类似的代码但没有找到。我是 android 编程的新手,任何帮助或链接都可能有所帮助。
原文由 Ranjith 发布,翻译遵循 CC BY-SA 4.0 许可协议
就像在 whatsapp 中一样,我需要一个重新编码按钮和一个幻灯片来取消和淡入淡出动画,我搜索了类似的代码但没有找到。我是 android 编程的新手,任何帮助或链接都可能有所帮助。
原文由 Ranjith 发布,翻译遵循 CC BY-SA 4.0 许可协议
你可以使用我制作 RecordView 的库
它易于设置,并且模拟与 WhatsApp 相同的行为。
只需添加视图 RecordView
和 RecordButton
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/parent_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.devlomi.recordview.MainActivity">
<com.devlomi.record_view.RecordView
android:id="@+id/record_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="@id/record_button"
app:slide_to_cancel_arrow="@drawable/ic_keyboard_arrow_left"
app:slide_to_cancel_text="Slide To Cancel"
app:slide_to_cancel_margin_right="10dp"/>
<com.devlomi.record_view.RecordButton
android:id="@+id/record_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="@drawable/bg_mic"
android:scaleType="centerInside"
app:src="@drawable/ic_mic_white"
/>
然后在你的活动中
RecordView recordView = (RecordView) findViewById(R.id.record_view);
RecordButton recordButton = (RecordButton)
findViewById(R.id.record_button);
//IMPORTANT
recordButton.setRecordView(recordView);
最后你可以处理记录状态
recordView.setOnRecordListener(this);
@Override
public void onStart() {
//Start Recording..
Log.d("RecordView", "onStart");
}
@Override
public void onCancel() {
//On Swipe To Cancel
Log.d("RecordView", "onCancel");
}
@Override
public void onFinish(long recordTime) {
//Stop Recording..
String time = getHumanTimeText(recordTime);
Log.d("RecordView", "onFinish");
Log.d("RecordTime", time);
}
@Override
public void onLessThanSecond() {
//When the record time is less than One Second
Log.d("RecordView", "onLessThanSecond");
}
原文由 3llomi 发布,翻译遵循 CC BY-SA 3.0 许可协议
3 回答824 阅读✓ 已解决
2 回答2.1k 阅读
2 回答948 阅读✓ 已解决
1 回答1.1k 阅读✓ 已解决
1 回答723 阅读✓ 已解决
2 回答843 阅读
2 回答781 阅读
我已经创建了一个 github 项目。你可以看看它 https://github.com/sarathnk/Audio