我想用拇指创建不会改变进度的搜索栏。我的搜索栏的进度必须与拇指位置分开设置。我该怎么办?
我应该说,我必须扩展Seekbar并覆盖一些方法。但我不明白哪个???哪种方法决定拇指的位置?哪个是决定进步?
Please help me!!
Thanks at advance!
答案 0 :(得分:0)
尝试使用不同的drawbles
让我举个例子:
您的code
的.java
import android.os.Bundle;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.widget.SeekBar;
public class MainActivity extends Activity {
private SeekBar seekBar1;
private SeekBar seekBar2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
seekBar1 = (SeekBar) findViewById(R.id.seekBar1);
seekBar2 = (SeekBar) findViewById(R.id.seekBar2);
seekBar1.setProgress(15);
seekBar2.setProgress(55);
Drawable ii = getResources().getDrawable(R.drawable.ii);
// Drawable iii = getResources().getDrawable(R.drawable.ii);
seekBar1.setThumb(ii);
seekBar2.setThumb(ii);
}
}
你的问题:
你可以做的是simple
只需重命名相同的drawable:
import android.os.Bundle;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.widget.SeekBar;
public class MainActivity extends Activity {
private SeekBar seekBar1;
private SeekBar seekBar2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
seekBar1 = (SeekBar) findViewById(R.id.seekBar1);
seekBar2 = (SeekBar) findViewById(R.id.seekBar2);
seekBar1.setProgress(15);
seekBar2.setProgress(55);
Drawable ii = getResources().getDrawable(R.drawable.ii);
Drawable iii = getResources().getDrawable(R.drawable.ii);
seekBar1.setThumb(ii);
seekBar2.setThumb(iii);
}
}
这就是结果:
希望有所帮助!! :)