2017-10-31 5 views
0

Ich mag zeichnen Bild auf Top in jedem Bogen von CanvasWie Bitmap-Bild auf der Oberseite in Bogen

private void drawImage(Canvas canvas, float tempAngle, Bitmap bitmap,String mValue) { 
    //get every arc img width and angle 
    int imgWidth = (radius/mWheelItems.size()); 
    //int imgWidth = (radius/3); 
    float angle = (float) ((tempAngle + 360/mWheelItems.size() /2) * Math.PI/180); 
    //calculate x and y 
    int x = (int) (center + radius/2/2 * Math.cos(angle)); 
    int y = (int) (center + radius/2/2 * Math.sin(angle)); 

    int top=y - imgWidth/2; 
    int bottom=y +imgWidth/2; 

    int left=x - imgWidth /2; 
    int right=x + imgWidth/2; 

     Rect rect = new Rect(left, top, right, bottom); 

       final Rect rect1 = new Rect(x - imgWidth /2 , y - imgWidth/2 , bitmap.getWidth() , bitmap.getHeight()); 

    canvas.drawBitmap(bitmap, null, rect, null); 
} 

Arc wird entsprechend die Größe der Elemente

Das Ergebnis wird gezeigt, wie zeichnen dass

enter image description here

Aber will ich das Bild Bitmap auf wie die von rect gezeigt. Red wollen auch große Größe von Bildern oder Bitmap

enter image description here

+0

Bitte lesen Sie es vor Downvote –

Antwort

0

gelöst durch spezifische Tab und Big Screen Tablets

Ändern Sie die X- und Y-Koordination nach unten

if(tempAngle==0) { 
     x = x + 50; 
    } 

    if(tempAngle==60) { 
     y = y + 50; 
    } 
    if(tempAngle==120) { 

     imgWidth = imgWidth-12; 
     y = y + 20; 
     x = x - 40; 
    } 
    if(tempAngle==180) { 
     imgWidth = imgWidth+12; 
     x = x - 50; 
    } 
    if(tempAngle==240) { 
     y = y - 50; 
    } 
    if(tempAngle==300) { 
     y = y - 20; 
     x = x + 40; 
    } 
Verwandte Themen