垂直和反向搜索栏 [英] Vertical and inverted SeekBar

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

问题描述

我一直在寻找一个垂直搜索栏的实现,发现这个:极品<实施>垂直搜索栏!

I was looking for an implementation of a vertical SeekBar and found this: Need <working> vertical SeekBar!

它工作正常。不过,我希望它是逆转,E.I分钟是在上面,max是在底部。这可能吗?我试着将它在不同程度上,但没有成功旋转。

It works fine. However I want it to be "reversed", e.i min is on top and max is at the bottom. Is this possible? I've tried to rotate it in different degrees but with no success.

推荐答案

我在你的问题,并制定了一个解决方案就出来了。我已经做了我们答案这里。 我已经修改了code点点,也取得了自己的目标。这里是链接到我的项目,

I have worked on your problem and came out with a solution. I have made us of the answer here. I have modified the code little bit and have achieved your goal. Here is the link to my project,

https://github.com/AndroSelva/Vertical-SeekBar-Android

刚刚在的onDraw()稍加修改,

Just a little modification in the onDraw(),

protected void onDraw(Canvas c) {
    c.rotate(90);
    c.translate(0, -getWidth());

    super.onDraw(c);
}

和onTouchEvent()

and onTouchEvent(),

switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
        case MotionEvent.ACTION_MOVE:
        case MotionEvent.ACTION_UP:
            int i=0;
            i=getMax() - (int) (getMax() * event.getY() / getHeight());
            setProgress(100-i);
            Log.i("Progress",getProgress()+"");
            onSizeChanged(getWidth(), getHeight(), 0, 0);
            break;

        case MotionEvent.ACTION_CANCEL:
            break;
    }

这篇关于垂直和反向搜索栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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