I have a custom Relative Layout(a class extended to RelativeLayout). I draw some bitmaps on a canvas using the method dispatchDraw(). And I want to show an Edit text box on top this canvas. So I create a new instance of EditText and bring it to front. EditText adds to the layout but doesn't come to front. When I remove canvas drawing code the edit text appears. Help me if you know a way to bring the EditText to the front of the canvas.
public class EditCardLayout extends RelativeLayout {
public EditCardLayout (Context context, AttributeSet attrs) {
super(context, attrs);
this.context = context;
editText = new EditText(context);
editText.setText("My Text");
addView( editText );
editText.bringToFront();
}
@Override
protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
// some bitmaps are drawn here...
}
}
XML :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#eceadb"
android:gravity="center">
<editCard.EditCardLayout
android:id="@+id/cardEditView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
</RelativeLayout>