我如何做一个搜索栏,其initail进步是零,在中间开始 [英] How do I make a seekbar whose initail progress which is zero, starts in the middle
问题描述
我想自定义搜索栏的图像中显示如下。
I want to customize the SeekBar as shown below in the image.
我在编程初学者,我看了看教程,但每一个地方的进展开始在最左边的角落。是否有人可以指导我如何可以自定义搜索栏。
I'm a beginner in programming and I looked for tutorials, but every where the progress starts in the leftmost corner. Can someone please guide me how can I customize the SeekBar.
所以,在onProgresschanged。
So In onProgresschanged.
@Override
public void onProgressChanged(SeekBar seekBar,int progress, boolean fromUser) {
brightness = progress;
putGestureImageOnScreen(doBrightness(imageBitmap, brightness));
}
感谢。
推荐答案
Seekbars在Android中不能有负值。假设你已经指定了100的数值为您最大范围的进度条(使用SETMAX(100),或在XML文件中使用的android例如:最大=100),那么你可以使用这个方法来移动你进度条,只要你想中间(例如,在您的Activity.onCreate()或任何其他地方)
Seekbars in Android cannot have negative values. Assuming you have specified a value of '100' for your maximum range of the progress bar (for example using setMax(100) or in your xml file using android:max="100"), then you can use this method to move your progress bar to the middle whenever you want (for example in your Activity.onCreate() or wherever else)
yourProgressBar.setProgress(50);
之后,你可以使用得到进度值:
After that you can get the progress value using:
int progress = yourProgressBar.getProgress();
如果你想有(EG)之间的进度值-50到+50,那么你可以简单地使用:
If you want to have a progress value between (e.g.) -50 to +50, then you can simply use:
int progress = yourProgressBar.getProgress();
progress -= 50;
祝你好运。
这篇关于我如何做一个搜索栏,其initail进步是零,在中间开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!