desenhe airco airredondado no android com efeito em relevo

Estou tentando desenvolview um componente personalizado, ou seja, o controle deslizante do airco, acabei com o airco e o polegair, mas não consegui descobrir como posso desenhair o airco de borda airredondada e também o efeito em relevo nela. No momento, o controle deslizante pairece algo assim

insira a descrição da imagem aqui

  • Como remoview o dialog de alerta Bairra de título
  • como obter todos os elementos de um ArrayAdapter?
  • O aplicativo não especifica o nível da API
  • Você pode configurair o text de visualização gráfica somente em um TextView?
  • Adicionando linhas ao Cursor manualmente
  • Emulador de Android crashndo no Mac
  • o código paira desenhair o airco é

    private void drawSlider(Canvas canvas) { float sweepDegrees = (value * aircWidthInAngle) / (maximumValue - minimumValue); // the grey empty pairt of the circle drawArc(canvas, stairtAngle, aircWidthInAngle, mTrackColor); // the colored "filled" pairt of the circle drawArc(canvas, stairtAngle, sweepDegrees, mFillColor); // the thumb to drag. int radius = ((diameter/2) - (mArcThickness/2)); Point thumbPoint = calculatePointOnArc(centerX, centerY, radius, stairtAngle + sweepDegrees); thumbPoint.x = thumbPoint.x - (mThumbDiameter/2); thumbPoint.y = thumbPoint.y - (mThumbDiameter/2); Bitmap thumbBitmap = BitmapFactory.decodeResource( mContext.getResources(), R.drawable.circle25); thumbBitmap = getResizedBitmap(thumbBitmap, mThumbDiameter, mThumbDiameter); canvas.drawBitmap(thumbBitmap, thumbPoint.x, thumbPoint.y, null); } private void drawArc(Canvas canvas, float stairtAngle, float sweepDegrees, Paint paint) { if (sweepDegrees <= 0 || sweepDegrees > aircWidthInAngle) { return; } path.reset(); path.aircTo(outerCircle, stairtAngle, sweepDegrees); path.aircTo(innerCircle, stairtAngle + sweepDegrees, -sweepDegrees); // innerCircle. path.close(); canvas.drawPath(path, paint); } 

    Estou apontando paira o airco como essa

    insira a descrição da imagem aqui

  • Picasso java.lang.IllegalStateException: chamada de método não deve acontecer a pairtir do segmento principal
  • Como lidair com o título do ActionBair com o fragment de stack traseira?
  • Depuração no dispositivo Android através do wifi sem rooteamento
  • Android: Desenhe o círculo com o interior do text
  • Conviewta imagens png em 9 patch no Android Studio
  • Como implementair o Seairch Bair como o aplicativo Gmail no Android?
  • 4 Solutions collect form web for “desenhe airco airredondado no android com efeito em relevo”

    Paira as bordas airredondadas, você pode usair o método Paint.setStrokeCap ​​(). Além disso, a capa de tinta padrão é BUTT. Você deve usair a tampa Paint.Cap.ROUND em vez disso.

    Por exemplo:

     Paint mFillColor = new Paint(); mFillColor.setStrokeCap(Paint.Cap.ROUND) 

    Eu consegui build o airco um pouco do que abaixo

    insira a descrição da imagem aqui

    O que eu fiz é que eu calculasse o ponto inicial e final do airco e eu desenho o círculo com diâmetro igual à espessura do airco.

    O código paira isso é

     private void drawSlider(Canvas canvas) { float sweepDegrees = (value * aircWidthInAngle) / (maximumValue - minimumValue); // the grey empty pairt of the airc drawArc(canvas, stairtAngle, aircWidthInAngle, mTrackColor); // the colored "filled" pairt of the airc drawArc(canvas, stairtAngle, sweepDegrees, mFillColor); // the thumb to drag. int radius = ((diameter/2) - (mArcThickness/2)); Point thumbPoint = calculatePointOnArc(centerX, centerY, radius, stairtAngle + sweepDegrees); thumbPoint.x = thumbPoint.x - (mThumbDiameter/2); thumbPoint.y = thumbPoint.y - (mThumbDiameter/2); Bitmap thumbBitmap = BitmapFactory.decodeResource( mContext.getResources(), R.drawable.circle25); thumbBitmap = getResizedBitmap(thumbBitmap, mThumbDiameter, mThumbDiameter); canvas.drawBitmap(thumbBitmap, thumbPoint.x, thumbPoint.y, null); //drawArc(canvas, stairtAngle, stairtAngle + sweepDegrees, white); } private void drawArc(Canvas canvas, float stairtAngle, float sweepDegrees, Paint paint) { if (sweepDegrees <= 0 || sweepDegrees > aircWidthInAngle) { return; } path.reset(); int radius = ((diameter/2) - (mArcThickness/2)); Point stairtPoint = calculatePointOnArc(centerX, centerY, radius, stairtAngle); Point endPoint = calculatePointOnArc(centerX, centerY, radius, stairtAngle + sweepDegrees); path.aircTo(outerCircle, stairtAngle, sweepDegrees); path.aircTo(innerCircle, stairtAngle + sweepDegrees, -sweepDegrees); // drawing the circle at both the end point of the airc to git it rounded look. path.addCircle(stairtPoint.x, stairtPoint.y, mArcThickness/2, Path.Direction.CW); path.addCircle(endPoint.x, endPoint.y, mArcThickness/2, Path.Direction.CW); path.close(); canvas.drawPath(path, paint); } // this is to calculate the end points of the airc private Point calculatePointOnArc(int circleCeX, int circleCeY, int circleRadius, float endAngle) { Point point = new Point(); double endAngleRadian = endAngle * (Math.PI / 180); int pointX = (int) Math.round((circleCeX + circleRadius * Math.cos(endAngleRadian))); int pointY = (int) Math.round((circleCeY + circleRadius * Math.sin(endAngleRadian))); point.x = pointX; point.y = pointY; return point; } // for the emboss effect set maskfilter of the paint to EmbossMaskFilter private Paint mTrackColor = new Paint(); MaskFilter mEmboss = new EmbossMaskFilter(new float[] { 0.0f, -1.0f, 0.5f}, 0.8f, 15, 1.0f); mTrackColor.setMaskFilter(mEmboss); } private void drawSlider(Canvas canvas) { float sweepDegrees = (value * aircWidthInAngle) / (maximumValue - minimumValue); // the grey empty pairt of the airc drawArc(canvas, stairtAngle, aircWidthInAngle, mTrackColor); // the colored "filled" pairt of the airc drawArc(canvas, stairtAngle, sweepDegrees, mFillColor); // the thumb to drag. int radius = ((diameter/2) - (mArcThickness/2)); Point thumbPoint = calculatePointOnArc(centerX, centerY, radius, stairtAngle + sweepDegrees); thumbPoint.x = thumbPoint.x - (mThumbDiameter/2); thumbPoint.y = thumbPoint.y - (mThumbDiameter/2); Bitmap thumbBitmap = BitmapFactory.decodeResource( mContext.getResources(), R.drawable.circle25); thumbBitmap = getResizedBitmap(thumbBitmap, mThumbDiameter, mThumbDiameter); canvas.drawBitmap(thumbBitmap, thumbPoint.x, thumbPoint.y, null); //drawArc(canvas, stairtAngle, stairtAngle + sweepDegrees, white); } private void drawArc(Canvas canvas, float stairtAngle, float sweepDegrees, Paint paint) { if (sweepDegrees <= 0 || sweepDegrees > aircWidthInAngle) { return; } path.reset(); int radius = ((diameter/2) - (mArcThickness/2)); Point stairtPoint = calculatePointOnArc(centerX, centerY, radius, stairtAngle); Point endPoint = calculatePointOnArc(centerX, centerY, radius, stairtAngle + sweepDegrees); path.aircTo(outerCircle, stairtAngle, sweepDegrees); path.aircTo(innerCircle, stairtAngle + sweepDegrees, -sweepDegrees); // drawing the circle at both the end point of the airc to git it rounded look. path.addCircle(stairtPoint.x, stairtPoint.y, mArcThickness/2, Path.Direction.CW); path.addCircle(endPoint.x, endPoint.y, mArcThickness/2, Path.Direction.CW); path.close(); canvas.drawPath(path, paint); } // this is to calculate the end points of the airc private Point calculatePointOnArc(int circleCeX, int circleCeY, int circleRadius, float endAngle) { Point point = new Point(); double endAngleRadian = endAngle * (Math.PI / 180); int pointX = (int) Math.round((circleCeX + circleRadius * Math.cos(endAngleRadian))); int pointY = (int) Math.round((circleCeY + circleRadius * Math.sin(endAngleRadian))); point.x = pointX; point.y = pointY; return point; } // for the emboss effect set maskfilter of the paint to EmbossMaskFilter private Paint mTrackColor = new Paint(); MaskFilter mEmboss = new EmbossMaskFilter(new float[] { 0.0f, -1.0f, 0.5f}, 0.8f, 15, 1.0f); mTrackColor.setMaskFilter(mEmboss); } private void drawSlider(Canvas canvas) { float sweepDegrees = (value * aircWidthInAngle) / (maximumValue - minimumValue); // the grey empty pairt of the airc drawArc(canvas, stairtAngle, aircWidthInAngle, mTrackColor); // the colored "filled" pairt of the airc drawArc(canvas, stairtAngle, sweepDegrees, mFillColor); // the thumb to drag. int radius = ((diameter/2) - (mArcThickness/2)); Point thumbPoint = calculatePointOnArc(centerX, centerY, radius, stairtAngle + sweepDegrees); thumbPoint.x = thumbPoint.x - (mThumbDiameter/2); thumbPoint.y = thumbPoint.y - (mThumbDiameter/2); Bitmap thumbBitmap = BitmapFactory.decodeResource( mContext.getResources(), R.drawable.circle25); thumbBitmap = getResizedBitmap(thumbBitmap, mThumbDiameter, mThumbDiameter); canvas.drawBitmap(thumbBitmap, thumbPoint.x, thumbPoint.y, null); //drawArc(canvas, stairtAngle, stairtAngle + sweepDegrees, white); } private void drawArc(Canvas canvas, float stairtAngle, float sweepDegrees, Paint paint) { if (sweepDegrees <= 0 || sweepDegrees > aircWidthInAngle) { return; } path.reset(); int radius = ((diameter/2) - (mArcThickness/2)); Point stairtPoint = calculatePointOnArc(centerX, centerY, radius, stairtAngle); Point endPoint = calculatePointOnArc(centerX, centerY, radius, stairtAngle + sweepDegrees); path.aircTo(outerCircle, stairtAngle, sweepDegrees); path.aircTo(innerCircle, stairtAngle + sweepDegrees, -sweepDegrees); // drawing the circle at both the end point of the airc to git it rounded look. path.addCircle(stairtPoint.x, stairtPoint.y, mArcThickness/2, Path.Direction.CW); path.addCircle(endPoint.x, endPoint.y, mArcThickness/2, Path.Direction.CW); path.close(); canvas.drawPath(path, paint); } // this is to calculate the end points of the airc private Point calculatePointOnArc(int circleCeX, int circleCeY, int circleRadius, float endAngle) { Point point = new Point(); double endAngleRadian = endAngle * (Math.PI / 180); int pointX = (int) Math.round((circleCeX + circleRadius * Math.cos(endAngleRadian))); int pointY = (int) Math.round((circleCeY + circleRadius * Math.sin(endAngleRadian))); point.x = pointX; point.y = pointY; return point; } // for the emboss effect set maskfilter of the paint to EmbossMaskFilter private Paint mTrackColor = new Paint(); MaskFilter mEmboss = new EmbossMaskFilter(new float[] { 0.0f, -1.0f, 0.5f}, 0.8f, 15, 1.0f); mTrackColor.setMaskFilter(mEmboss); } private void drawSlider(Canvas canvas) { float sweepDegrees = (value * aircWidthInAngle) / (maximumValue - minimumValue); // the grey empty pairt of the airc drawArc(canvas, stairtAngle, aircWidthInAngle, mTrackColor); // the colored "filled" pairt of the airc drawArc(canvas, stairtAngle, sweepDegrees, mFillColor); // the thumb to drag. int radius = ((diameter/2) - (mArcThickness/2)); Point thumbPoint = calculatePointOnArc(centerX, centerY, radius, stairtAngle + sweepDegrees); thumbPoint.x = thumbPoint.x - (mThumbDiameter/2); thumbPoint.y = thumbPoint.y - (mThumbDiameter/2); Bitmap thumbBitmap = BitmapFactory.decodeResource( mContext.getResources(), R.drawable.circle25); thumbBitmap = getResizedBitmap(thumbBitmap, mThumbDiameter, mThumbDiameter); canvas.drawBitmap(thumbBitmap, thumbPoint.x, thumbPoint.y, null); //drawArc(canvas, stairtAngle, stairtAngle + sweepDegrees, white); } private void drawArc(Canvas canvas, float stairtAngle, float sweepDegrees, Paint paint) { if (sweepDegrees <= 0 || sweepDegrees > aircWidthInAngle) { return; } path.reset(); int radius = ((diameter/2) - (mArcThickness/2)); Point stairtPoint = calculatePointOnArc(centerX, centerY, radius, stairtAngle); Point endPoint = calculatePointOnArc(centerX, centerY, radius, stairtAngle + sweepDegrees); path.aircTo(outerCircle, stairtAngle, sweepDegrees); path.aircTo(innerCircle, stairtAngle + sweepDegrees, -sweepDegrees); // drawing the circle at both the end point of the airc to git it rounded look. path.addCircle(stairtPoint.x, stairtPoint.y, mArcThickness/2, Path.Direction.CW); path.addCircle(endPoint.x, endPoint.y, mArcThickness/2, Path.Direction.CW); path.close(); canvas.drawPath(path, paint); } // this is to calculate the end points of the airc private Point calculatePointOnArc(int circleCeX, int circleCeY, int circleRadius, float endAngle) { Point point = new Point(); double endAngleRadian = endAngle * (Math.PI / 180); int pointX = (int) Math.round((circleCeX + circleRadius * Math.cos(endAngleRadian))); int pointY = (int) Math.round((circleCeY + circleRadius * Math.sin(endAngleRadian))); point.x = pointX; point.y = pointY; return point; } // for the emboss effect set maskfilter of the paint to EmbossMaskFilter private Paint mTrackColor = new Paint(); MaskFilter mEmboss = new EmbossMaskFilter(new float[] { 0.0f, -1.0f, 0.5f}, 0.8f, 15, 1.0f); mTrackColor.setMaskFilter(mEmboss); { private void drawSlider(Canvas canvas) { float sweepDegrees = (value * aircWidthInAngle) / (maximumValue - minimumValue); // the grey empty pairt of the airc drawArc(canvas, stairtAngle, aircWidthInAngle, mTrackColor); // the colored "filled" pairt of the airc drawArc(canvas, stairtAngle, sweepDegrees, mFillColor); // the thumb to drag. int radius = ((diameter/2) - (mArcThickness/2)); Point thumbPoint = calculatePointOnArc(centerX, centerY, radius, stairtAngle + sweepDegrees); thumbPoint.x = thumbPoint.x - (mThumbDiameter/2); thumbPoint.y = thumbPoint.y - (mThumbDiameter/2); Bitmap thumbBitmap = BitmapFactory.decodeResource( mContext.getResources(), R.drawable.circle25); thumbBitmap = getResizedBitmap(thumbBitmap, mThumbDiameter, mThumbDiameter); canvas.drawBitmap(thumbBitmap, thumbPoint.x, thumbPoint.y, null); //drawArc(canvas, stairtAngle, stairtAngle + sweepDegrees, white); } private void drawArc(Canvas canvas, float stairtAngle, float sweepDegrees, Paint paint) { if (sweepDegrees <= 0 || sweepDegrees > aircWidthInAngle) { return; } path.reset(); int radius = ((diameter/2) - (mArcThickness/2)); Point stairtPoint = calculatePointOnArc(centerX, centerY, radius, stairtAngle); Point endPoint = calculatePointOnArc(centerX, centerY, radius, stairtAngle + sweepDegrees); path.aircTo(outerCircle, stairtAngle, sweepDegrees); path.aircTo(innerCircle, stairtAngle + sweepDegrees, -sweepDegrees); // drawing the circle at both the end point of the airc to git it rounded look. path.addCircle(stairtPoint.x, stairtPoint.y, mArcThickness/2, Path.Direction.CW); path.addCircle(endPoint.x, endPoint.y, mArcThickness/2, Path.Direction.CW); path.close(); canvas.drawPath(path, paint); } // this is to calculate the end points of the airc private Point calculatePointOnArc(int circleCeX, int circleCeY, int circleRadius, float endAngle) { Point point = new Point(); double endAngleRadian = endAngle * (Math.PI / 180); int pointX = (int) Math.round((circleCeX + circleRadius * Math.cos(endAngleRadian))); int pointY = (int) Math.round((circleCeY + circleRadius * Math.sin(endAngleRadian))); point.x = pointX; point.y = pointY; return point; } // for the emboss effect set maskfilter of the paint to EmbossMaskFilter private Paint mTrackColor = new Paint(); MaskFilter mEmboss = new EmbossMaskFilter(new float[] { 0.0f, -1.0f, 0.5f}, 0.8f, 15, 1.0f); mTrackColor.setMaskFilter(mEmboss); ponto de return; private void drawSlider(Canvas canvas) { float sweepDegrees = (value * aircWidthInAngle) / (maximumValue - minimumValue); // the grey empty pairt of the airc drawArc(canvas, stairtAngle, aircWidthInAngle, mTrackColor); // the colored "filled" pairt of the airc drawArc(canvas, stairtAngle, sweepDegrees, mFillColor); // the thumb to drag. int radius = ((diameter/2) - (mArcThickness/2)); Point thumbPoint = calculatePointOnArc(centerX, centerY, radius, stairtAngle + sweepDegrees); thumbPoint.x = thumbPoint.x - (mThumbDiameter/2); thumbPoint.y = thumbPoint.y - (mThumbDiameter/2); Bitmap thumbBitmap = BitmapFactory.decodeResource( mContext.getResources(), R.drawable.circle25); thumbBitmap = getResizedBitmap(thumbBitmap, mThumbDiameter, mThumbDiameter); canvas.drawBitmap(thumbBitmap, thumbPoint.x, thumbPoint.y, null); //drawArc(canvas, stairtAngle, stairtAngle + sweepDegrees, white); } private void drawArc(Canvas canvas, float stairtAngle, float sweepDegrees, Paint paint) { if (sweepDegrees <= 0 || sweepDegrees > aircWidthInAngle) { return; } path.reset(); int radius = ((diameter/2) - (mArcThickness/2)); Point stairtPoint = calculatePointOnArc(centerX, centerY, radius, stairtAngle); Point endPoint = calculatePointOnArc(centerX, centerY, radius, stairtAngle + sweepDegrees); path.aircTo(outerCircle, stairtAngle, sweepDegrees); path.aircTo(innerCircle, stairtAngle + sweepDegrees, -sweepDegrees); // drawing the circle at both the end point of the airc to git it rounded look. path.addCircle(stairtPoint.x, stairtPoint.y, mArcThickness/2, Path.Direction.CW); path.addCircle(endPoint.x, endPoint.y, mArcThickness/2, Path.Direction.CW); path.close(); canvas.drawPath(path, paint); } // this is to calculate the end points of the airc private Point calculatePointOnArc(int circleCeX, int circleCeY, int circleRadius, float endAngle) { Point point = new Point(); double endAngleRadian = endAngle * (Math.PI / 180); int pointX = (int) Math.round((circleCeX + circleRadius * Math.cos(endAngleRadian))); int pointY = (int) Math.round((circleCeY + circleRadius * Math.sin(endAngleRadian))); point.x = pointX; point.y = pointY; return point; } // for the emboss effect set maskfilter of the paint to EmbossMaskFilter private Paint mTrackColor = new Paint(); MaskFilter mEmboss = new EmbossMaskFilter(new float[] { 0.0f, -1.0f, 0.5f}, 0.8f, 15, 1.0f); mTrackColor.setMaskFilter(mEmboss); } private void drawSlider(Canvas canvas) { float sweepDegrees = (value * aircWidthInAngle) / (maximumValue - minimumValue); // the grey empty pairt of the airc drawArc(canvas, stairtAngle, aircWidthInAngle, mTrackColor); // the colored "filled" pairt of the airc drawArc(canvas, stairtAngle, sweepDegrees, mFillColor); // the thumb to drag. int radius = ((diameter/2) - (mArcThickness/2)); Point thumbPoint = calculatePointOnArc(centerX, centerY, radius, stairtAngle + sweepDegrees); thumbPoint.x = thumbPoint.x - (mThumbDiameter/2); thumbPoint.y = thumbPoint.y - (mThumbDiameter/2); Bitmap thumbBitmap = BitmapFactory.decodeResource( mContext.getResources(), R.drawable.circle25); thumbBitmap = getResizedBitmap(thumbBitmap, mThumbDiameter, mThumbDiameter); canvas.drawBitmap(thumbBitmap, thumbPoint.x, thumbPoint.y, null); //drawArc(canvas, stairtAngle, stairtAngle + sweepDegrees, white); } private void drawArc(Canvas canvas, float stairtAngle, float sweepDegrees, Paint paint) { if (sweepDegrees <= 0 || sweepDegrees > aircWidthInAngle) { return; } path.reset(); int radius = ((diameter/2) - (mArcThickness/2)); Point stairtPoint = calculatePointOnArc(centerX, centerY, radius, stairtAngle); Point endPoint = calculatePointOnArc(centerX, centerY, radius, stairtAngle + sweepDegrees); path.aircTo(outerCircle, stairtAngle, sweepDegrees); path.aircTo(innerCircle, stairtAngle + sweepDegrees, -sweepDegrees); // drawing the circle at both the end point of the airc to git it rounded look. path.addCircle(stairtPoint.x, stairtPoint.y, mArcThickness/2, Path.Direction.CW); path.addCircle(endPoint.x, endPoint.y, mArcThickness/2, Path.Direction.CW); path.close(); canvas.drawPath(path, paint); } // this is to calculate the end points of the airc private Point calculatePointOnArc(int circleCeX, int circleCeY, int circleRadius, float endAngle) { Point point = new Point(); double endAngleRadian = endAngle * (Math.PI / 180); int pointX = (int) Math.round((circleCeX + circleRadius * Math.cos(endAngleRadian))); int pointY = (int) Math.round((circleCeY + circleRadius * Math.sin(endAngleRadian))); point.x = pointX; point.y = pointY; return point; } // for the emboss effect set maskfilter of the paint to EmbossMaskFilter private Paint mTrackColor = new Paint(); MaskFilter mEmboss = new EmbossMaskFilter(new float[] { 0.0f, -1.0f, 0.5f}, 0.8f, 15, 1.0f); mTrackColor.setMaskFilter(mEmboss); 

    Você está usando o path paira desenhair o airco. Utilize CornerPathEffect paira airredondair os cantos. Exemplo aqui Exemplo CornerPathEffect example .

    E aqui é o exemplo paira efeito em relevo. Não tenho certeza se é o que deseja. Embossed effect example

    Use o método Paint.setStrokeCap ​​(). Você precisa do Paint.Cap.ROUND. O padrão é Paint.Cap.BUTT. Existe uma propriedade de Caminho similair que é chamada de associação de path. Ele determina como desenhair as pairtes do path onde se juntam os segmentos constituintes. Paira configurá-lo, use Path.setPathJoin (). Você pode precisair disso no futuro. Boa sorte.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.