android - 可以在 android 的 edittext 中添加语音操作按钮吗

标签 android android-edittext voice-recognition

如何在编辑文本中创建语音按钮,例如使用语音按钮进行谷歌搜索。请参阅下面的图片网址,就像我想要的那样。有人建议我吗?

Sample Image EditText with Mic

最佳答案

<LinearLayout
        android:id="@+id/ll"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginLeft="5dp"
        android:layout_weight="0.8"
        android:background="@drawable/dialog_edt"
        android:orientation="horizontal"
        android:weightSum="1" >

        <EditText
            android:id="@+id/edt_Contact"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_weight="0.8"
            android:background="@android:color/transparent"
            android:imeOptions="actionDone"
            android:inputType="number|text|numberDecimal"
            android:paddingLeft="2dp"
            android:singleLine="true" />

        <ImageView
            android:id="@+id/iv_Mic"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginRight="2dp"
            android:layout_weight="0.2"
            android:src="@drawable/mic" />
</LinearLayout>

这样你就可以创建一个 Mic 的 clickListener 来做一些事情。

关于android - 可以在 android 的 edittext 中添加语音操作按钮吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25761990/

相关文章:

java - 我应该使用哪种语言进行编码以通过语音控制运动?

java - 如何根据给编辑 TextView 的计数值动态实现线性布局的代码

java - Android edittext 将每行上的文本获取到一个数组中并自动换行?

具有许多选项卡的 Android 选项卡布局

android - 您是否将真实图像(用于启动画面)转换为九色补丁?

android - EditText setError 在 BottomSheetDialog 中不合适

android - 如何将 AudioRecord 类中已识别的语音保存在文件中?

nlp - 自然语言搜索(用户意图搜索)

java - 应用程序崩溃 : class has no empty constructor

android - 如何在切换抽屉导航时使用 fragment 隐藏软输入键盘