小编Ala*_*lan的帖子

以编程方式更改搜索栏的大小但不能使拇指大于条形

我必须创建一个搜索栏,我可以通过编程方式更改几乎所有内容.现在我有一个问题是改变拇指和条形尺寸.如果酒吧比拇指更大或尺寸相同,一切都很好,但如果拇指比酒吧大,我不能让它显示整个拇指的正确尺寸.

这是我创建拇指的代码:

   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)

android scrollbar seekbar

7
推荐指数
1
解决办法
1万
查看次数

如何以编程方式在另一个shapeDrawable中绘制较小的ShapeDrawable

我试图在另一个圆圈内绘制一个较小的圆圈.这似乎很简单,但我遇到了麻烦,无法找到答案.我使用的代码是:

    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)

但那不起作用,会发生的是,较小的圆圈会变得像较大的圆圈一样大.所以唯一显示的是黑色圆圈,大圆圈的大小.如果有人可以提供帮助,我会帮助你.提前致谢.

android drawing dynamic shapes drawable

6
推荐指数
1
解决办法
8094
查看次数

标签 统计

android ×2

drawable ×1

drawing ×1

dynamic ×1

scrollbar ×1

seekbar ×1

shapes ×1