Android 如何制作左侧扫码标志的圆角搜索框
时间: 2023-05-17 14:03:53 浏览: 111
要制作左侧扫码标志的圆角搜索框,可以使用 Android 的 Material Design 风格的 TextInputLayout 和 TextInputEditText 组件。具体步骤如下:
1. 在布局文件中添加 TextInputLayout 和 TextInputEditText 组件,设置其外观和样式。
2. 在 TextInputLayout 组件中添加一个 ImageView 组件,用于显示左侧扫码标志。
3. 在 TextInputEditText 组件中设置圆角样式,可以使用 background 属性设置背景颜色和圆角半径。
以下是示例代码:
```
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Search"
app:startIconDrawable="@drawable/ic_scan"
app:startIconContentDescription="Scan QR code">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/rounded_search_box"
android:padding="12dp" />
</com.google.android.material.textfield.TextInputLayout>
```
其中,@drawable/ic_scan 是左侧扫码标志的图标,@drawable/rounded_search_box 是圆角搜索框的背景。可以根据实际需求进行调整。