Android的搜索栏与浮点值 [英] Android seekbar with float values

查看:174
本文介绍了Android的搜索栏与浮点值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能最大值设置为 99,999 和分钟 <0.001 / code>在搜索栏?

How can I set the max value to 99,999 and min to 0.001 in seekbar ?

推荐答案

您不能。在搜索栏控件只接受其最大和目前的进展整数。你无法控制的最低,因为它始终是 0

You can't. The SeekBar widget only accepts ints for its max and current progress. You can't control the minimum, as it is always 0.

您可以用10的幂,使得小数消失乘以你需要的最大和目前的进展值。在搜索栏仍然会显示进度相同数量,因为它会用十进制值,因为进步是 CurrentValue的/ maxValue(最大值)的比率。正如你将用同样数量乘以两者的比例是相等的。例如:

You could multiply your required maximum and current progress values by a power of 10, such that the decimal goes away. The SeekBar will still show the same amount of progress as it would with a decimal value, as the progress is a ratio of currentValue/maxValue. As you'll be multiplying both by the same number, the ratios are equal. For example:

0.1/10 = 0.01

然而,如果你无论多在0.1和10×10摆脱了小数,你就会得到:

However, if you multiple both 0.1 and 10 by 10 to get rid of the decimal, you get:

1/100 = 0.01 //Same result

这篇关于Android的搜索栏与浮点值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆