Reputation: 11469
I am new to android and I have an image in my drawable folder which I was able to load as my background, now I would like to draw on top of the background but havent been able to, how can achieve this... I have the following, all i want is to draw a circle on top of the image background
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:id="@+id/my_view"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background">
</FrameLayout>
//MY ACTIVITY
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
//IN MY VIEW CLASS
public GameView(Context context, float x, float y, int r) {
super(context);
setFocusable(true);
mPaint.setColor(Color.YELLOW);
this.x = x;
this.y = y;
this.r = r;
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawCircle(x, y, r, mPaint);
}
Upvotes: 0
Views: 422
Reputation: 500
To set the image as background use ImageView in Absolute Layout.Enter code to set img as background :
Now you would be able to have circle over the image view
Upvotes: 1