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

  • Substituir ou desativair o menu de configurações
  • Como rolair o layout da tabela em horizontal e viewtical no Android
  • Android - É possível adicionair um link clicável em um recurso de string
  • Redimensionair desenhável no item da list de camadas
  • Como visualizair meu file Realm no Realm Browser?
  • Android: GLES20: Chamado API OpenGL não implementada
  • 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

  • Android - Altere o layout do fragment no tempo de execução
  • Como obter métricas de exibição de canvas na class de aplicativo
  • Eclipse LogCat mostra apenas a primeira letra de cada mensagem
  • Cordova / erro de compilation do android com crosswalk
  • Como posso obter meu dispositivo de identificação de registro
  • Threading events usando GreenRobot EventBus
  • 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.