No need to calculate anything, the only thing you need to do is to define shape of your imageButton inside button template xml (the drawable on).
so inside your UI layout xml file, ImageButton may be described like this
<ImageButton
android:id="@+id/button"
android:layout_width="300dp"
android:layout_height="300dp"
android:src="@drawable/yourIcon"
android:background="@drawable/button" <!-- PATTERN!! -->
android:contentDescription="obrazek"
android:padding="5dp"
android:layout_margin="1dp"
android:onClick="onClick"/>
and inside your pattern file just declare shape="oval" i.e. like this
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<gradient
android:startColor="#50d050"
android:endColor="#008000"
android:angle="270"/>
<stroke
android:width="1px"
android:color="#000000"/>
</shape>
It cannot be any more simple. :D