It is impossible to achieve manipulating background attribute within xml-files only. There are two options:
-
You cut/scale the bitmap programmatically with
Bitmap.createScaledBitmap(Bitmap src, int dstWidth, int dstHeight,
and set it as some
boolean filter)View
‘s background. -
You use
ImageView
instead of background placing it as the first layout’s element and specifyandroid:scaleType
attribute for it:<RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="https://stackoverflow.com/questions/9891065/@drawable/backgrnd" android:scaleType="centerCrop" /> ... rest layout components here ... </RelativeLayout>