【问题标题】:how can i change the android seekbar thumb of image within current progress如何在当前进度中更改图像的 android seekbar 拇指
【发布时间】:2013-11-30 06:30:54
【问题描述】:

我是 android 新手...我正在创建搜索栏...我想更改图像的拇指和每个进度值...但是当我移动拇指时,它会更改图像的拇指但它去了到搜索栏的开头。有没有人可以通过搜索栏进度移动不同拇指图像的解决方案?

这是我的代码

    final Drawable thumb1 = getResources().getDrawable( R.drawable.one);
    final Drawable thumb2 = getResources().getDrawable( R.drawable.two);
    final Drawable thumb3 = getResources().getDrawable( R.drawable.three);
    final Drawable thumb4 = getResources().getDrawable( R.drawable.four);



    thumb1.setBounds(new Rect(0, 0, thumb1.getIntrinsicWidth(),thumb1.getIntrinsicHeight()));
    thumb2.setBounds(new Rect(0, 0, thumb2.getIntrinsicWidth(),thumb2.getIntrinsicHeight()));
    thumb3.setBounds(new Rect(0, 0, thumb3.getIntrinsicWidth(),thumb3.getIntrinsicHeight()));
    thumb4.setBounds(new Rect(0, 0, thumb4.getIntrinsicWidth(),thumb4.getIntrinsicHeight()));


             seekbar1.setOnSeekBarChangeListener(new OnSeekBarChangeListener(){

            @Override
            public void onProgressChanged(SeekBar seekBar, int progress,
                    boolean fromUser) {


                 if(progress==0){
                    seekbar1.setThumb(thumb1);
                                //  seekbar1.setProgress(0);
                   }
                   else if(progress==1){
                            seekbar1.setThumb(thumb2);
                                //  seekbar1.setProgress(1);
                   }
                   else if(progress==2){
                    seekbar1.setThumb(thumb3);
                            //   seekbar1.setProgress(2);

                   }
                   else if(progress==3){                    
                                seekbar1.setThumb(thumb4);
                               //   seekbar1.setProgress(3);
                   }


            }

【问题讨论】:

    标签: android seekbar seekbarpreference


    【解决方案1】:

    遵循本指南
    http://javandroidevelop.blogspot.in/2012/09/cool-seekbar-custom-made-by-me.html
    既然你是新人,我建议你不要问这样的问题,而是阅读
    https://stackoverflow.com/about
    首先。

    【讨论】:

    • 谢谢,我看到了链接,它只改变了进度图像。但我想改变图像的拇指。我知道如何更改图像的拇指,但是当我移动拇指时,我无法更改当前进度中的图像拇指。你能帮助我吗。如何解决这个问题
    • @vignesh,你能告诉我如何改变图像的拇指
    猜你喜欢
    • 1970-01-01
    • 2015-05-11
    • 1970-01-01
    • 1970-01-01
    • 2020-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多