如何解决程序搜索
| 我正在以编程方式创建SeekBar,如下所示:SeekBar seekBar = new SeekBar(this);
seekBar.setMax(15);
seekBar.setIndeterminate(true);
seekBar.setMinimumWidth(200);
ShapeDrawable thumb = new ShapeDrawable(new ovalShape());
thumb.getPaint().setColor(0x00FF00);
thumb.setIntrinsicHeight(80);
thumb.setIntrinsicWidth(30);
seekBar.setThumb(thumb);
seekBar.setProgress(1);
但是我只能看到一个小的SeekBar。
可能是什么问题?
谢谢
解决方法
尝试以下代码
import android.app.Activity;
import android.graphics.Color;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout.LayoutParams;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
public class Sample2 extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
SeekBar seekBar = new SeekBar(this);
seekBar.setMax(15);
// seekBar.setIndeterminate(true);
ShapeDrawable thumb = new ShapeDrawable(new OvalShape());
thumb.setIntrinsicHeight(80);
thumb.setIntrinsicWidth(30);
seekBar.setThumb(thumb);
seekBar.setProgress(1);
seekBar.setVisibility(View.VISIBLE);
seekBar.setBackgroundColor(Color.BLUE);
LayoutParams lp = new LayoutParams(200,50);
seekBar.setLayoutParams(lp);
seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
public void onStopTrackingTouch(SeekBar arg0) {
// TODO Auto-generated method stub
System.out.println(\".....111.......\");
}
public void onStartTrackingTouch(SeekBar arg0) {
// TODO Auto-generated method stub
System.out.println(\".....222.......\");
}
public void onProgressChanged(SeekBar arg0,int arg1,boolean arg2) {
// TODO Auto-generated method stub
System.out.println(\".....333.......\"+arg1);
}
});
setContentView(seekBar);
}
}
谢谢
迪帕克
, 尝试取出可能有不良效果的seekBar.setIndeterminate(true);
。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。