使用Android SeekBar,您通常可以將拇指向左或向右拖動,黃色的進度顏色位於拇指左側。我想要的是完全相反,基本上翻轉拇指右側的黃色進度顏色並在y軸上翻轉整個SeekBar。Android SeekBar水平翻轉
任何人都可以指向正確的方向嗎?謝謝!
使用Android SeekBar,您通常可以將拇指向左或向右拖動,黃色的進度顏色位於拇指左側。我想要的是完全相反,基本上翻轉拇指右側的黃色進度顏色並在y軸上翻轉整個SeekBar。Android SeekBar水平翻轉
任何人都可以指向正確的方向嗎?謝謝!
擺弄了一些代碼後,我得到了它,它似乎工作得很好。希望它能幫助未來的其他人。
public class ReversedSeekBar extends SeekBar {
public ReversedSeekBar(Context context) {
super(context);
}
public ReversedSeekBar(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ReversedSeekBar(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onDraw(Canvas canvas) {
float px = this.getWidth()/2.0f;
float py = this.getHeight()/2.0f;
canvas.scale(-1, 1, px, py);
super.onDraw(canvas);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
event.setLocation(this.getWidth() - event.getX(), event.getY());
return super.onTouchEvent(event);
}
}
這與這兩個問題的幫助下一起拋出:
You should look into making a custom progress bar.考慮到你想要做什麼,你已經有了Android SDK所需的圖像。我會提取它們並相應地編輯它們。 Here's a tutorial to help get you started。
你試過seekbar.setRotation(180)?它將搜索欄翻轉180度並翻轉,這意味着左側是最大的,右側是0,拇指右側的顏色。不需要以這種方式創建自定義搜索欄。
謝謝!我是Android新手,仍然熟悉它。 – mhenry