在Java代码中围绕圆形路径绘制按钮需要帮助吗?

pen*_*ang 5 android

我可以得到圆形的中心点,所以我想在圆形的中心点周围绘制一些按钮,如图所示http://i.6.cn/cvbnm/50/97/b0/e7ed11251c3069fea4130c74b3ecb10c .png ,你能给我一些建议,链接到例子会更有用.这是我的代码

编辑:

public class drawCirPicture extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(new SampleView(this));
}

private static class SampleView extends View {
    private Bitmap mBitmap;




    public SampleView(Context context) {
        super(context);
        setFocusable(true);

        InputStream is = context.getResources().openRawResource(android.R.drawable.sym_call_outgoing);
        mBitmap = BitmapFactory.decodeStream(is);

    }

    @Override protected void onDraw(Canvas canvas) {
        canvas.drawColor(Color.GRAY);

        Paint p = new Paint();
        float centerY = 200;
        float centerX=130;

       double alpha = 0,wedge=0;
       double PI=Math.PI;

        float x,y;

        int radius=55;

        for (alpha = 0, wedge = 2 * PI / 4; alpha < 2 * PI; alpha += wedge)
        {
            x = (float) (centerX + radius * Math.cos(alpha));
            y = (float) (centerY + radius * Math.sin(alpha));
            canvas.drawBitmap(mBitmap, x, y, p);
        }


    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        // TODO Auto-generated method stub
        return super.onTouchEvent(event);
    }

    @Override
    public boolean performClick() {
        // TODO Auto-generated method stub
        return super.performClick();
    }
    }
}
Run Code Online (Sandbox Code Playgroud)

我能够将图像放在圆形路径中,但我无法实现每个图像的ontouch事件或onclick事件,并且centerX或centerY也位于屏幕的边缘,如何将图像放到广阔的区域屏幕.

Ama*_*dan 6

x = centerX + radius * cos(alpha)
y = centerY + radius * sin(alpha)
Run Code Online (Sandbox Code Playgroud)

哪里alpha是0和之间2 * PI.

三角学很酷.