В вашем примере вы рисуете вид на холсте, а не на холсте вида.Вы должны использовать простой подход, не раздувать макет, а загружать его нормально, затем найти корневой контейнер и установить его фон.Примерно так:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Paint paint = new Paint();
paint.setColor(Color.MAGENTA);
Bitmap bgr = Bitmap.createBitmap(480, 800, Bitmap.Config.ARGB_8888);
Canvas can = new Canvas(bgr);
can.drawRect(50, 50, 200, 200, paint);
LinearLayout ll = (LinearLayout) findViewById(R.id.ll);
ll.setBackgroundDrawable(new BitmapDrawable(bgr));
}
основной макет:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/ll">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>