<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="5dip" android:background="@drawable/icon"> </RelativeLayout>
Or use the following to set background programmatically:
layout = new AbsoluteLayout(this); Bitmap bitmap = BitmapFactory.decodeResource(this.getResources(), R.drawable.abc_bg_img); BitmapDrawable background = new BitmapDrawable(bitmap); layout.setBackgroundDrawable(background); ImageView imageView = new ImageView(this); imageView.setImageResource(R.drawable.img_name); imageView.setAdjustViewBounds(true); imageView.setLayoutParams(new AbsoluteLayout.LayoutParams(100, 100, 100, 100)); layout.addView(imageView); this.setContentView(layout);
2 How do I change location of a View item? Use setLeftAndRight() and setTopAndBottom(), remember to use view.invalidate() to trigger redraw. Comments
Use setLeftAndRight() and setTopAndBottom(), remember to use view.invalidate() to trigger redraw.