android - 如何在 Android 中制作像这样的自定义搜索栏?
问题描述
我如何设计自定义seekbar
下面的图像
有没有人有想法请指导我。提前感谢大家
解决方案
我认为这个图书馆会帮助你
- 将以下依赖项添加到您的 build.gradle 文件中。
implementation'com.kevalpatel2106:ruler-picker:1.1'
- 在您的 XML 布局中添加 RulerValuePicker。
<com.kevalpatel2106.rulerpicker.RulerValuePicker
android:id="@+id/ruler_picker"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@android:color/holo_orange_dark"
app:indicator_color="@android:color/white"
app:indicator_interval="14dp"
app:indicator_width="2dp"
app:max_value="120"
app:min_value="35"
app:notch_color="@android:color/white"
app:ruler_text_size="6sp"/>
- 爪哇:
rulerValuePicker.setValuePickerListener(new RulerValuePickerListener() {
@Override
public void onValueChange(final int selectedValue) {
//Value changed and the user stopped scrolling the ruler.
//Application can consider this value as final selected value.
}
@Override
public void onIntermediateValueChange(final int selectedValue) {
//Value changed but the user is still scrolling the ruler.
//This value is not final value. Application can utilize this value to display the current selected value.
}
});
- 科特林:
rulerValuePicker.setValuePickerListener(object : RulerValuePickerListener {
override fun onValueChange(value: Int) {
//Value changed and the user stopped scrolling the ruler.
//You can consider this value as final selected value.
}
override fun onIntermediateValueChange(selectedValue: Int) {
//Value changed but the user is still scrolling the ruler.
//This value is not final value. You can utilize this value to display the current selected value.
}
})
- 截图:
推荐阅读
- java - 改进计算余数的递归
- php - 我想同时使用两个数组值,例如 arr1[0] 和 arr2[0] 值,这些数组的长度在 php 中是相同的
- python - 如何使用 python boto3 更新 s3 中的 json?
- java - Java Play Framework 1.4x - 开发服务器
- git - git discard 专门更改暂存区
- cmake - 无论如何在CMake中动态查找库路径?
- html - 页面或视频上的简单密码字段
- javascript - 在 localeCompare() 方法中使用 locale 选项
- wpf - 如何将图像的平移限制在范围内
- compression - 压缩具有相似内容的 ISO 文件集合