我必须创建一个搜索栏,我可以通过编程方式更改几乎所有内容.现在我有一个问题是改变拇指和条形尺寸.如果酒吧比拇指更大或尺寸相同,一切都很好,但如果拇指比酒吧大,我不能让它显示整个拇指的正确尺寸.
这是我创建拇指的代码:
public void setSeekBarThumb(int width, int height, int rColor, int gColor, int bColor){
ShapeDrawable thumb = new ShapeDrawable( new OvalShape() );
thumb.setIntrinsicHeight( height );
thumb.setIntrinsicWidth( width );
thumb.setBounds(new Rect(0, 0, width, height));
StateListDrawable states = new StateListDrawable();
states.addState(new int[] {android.R.attr.state_pressed},thumb );//add to the state list with the state pressed
thumb = new ShapeDrawable( new OvalShape() );
thumb.setIntrinsicHeight( height );
thumb.setIntrinsicWidth( width );
thumb.setBounds(new Rect(0, 0, width, height));
states.addState(new int[] { },thumb );//add to the state list with no state …Run Code Online (Sandbox Code Playgroud) 我试图在另一个圆圈内绘制一个较小的圆圈.这似乎很简单,但我遇到了麻烦,无法找到答案.我使用的代码是:
ShapeDrawable biggerCircle= new ShapeDrawable( new OvalShape());
biggerCircle.setIntrinsicHeight( 60 );
biggerCircle.setIntrinsicWidth( 60);
biggerCircle.setBounds(new Rect(0, 0, 60, 60));
biggerCircle.getPaint().setColor(Color.BLUE);
ShapeDrawable smallerCircle= new ShapeDrawable( new OvalShape());
smallerCircle.setIntrinsicHeight( 10 );
smallerCircle.setIntrinsicWidth( 10);
smallerCircle.setBounds(new Rect(0, 0, 10, 10));
smallerCircle.getPaint().setColor(Color.BLACK);
smallerCircle.setPadding(50,50,50,50);
LayerDrawable composite1 = new LayerDrawable(new Drawable[] biggerCircle,smallerCircle,});
Run Code Online (Sandbox Code Playgroud)
但那不起作用,会发生的是,较小的圆圈会变得像较大的圆圈一样大.所以唯一显示的是黑色圆圈,大圆圈的大小.如果有人可以提供帮助,我会帮助你.提前致谢.