I am trying to set a square shaped bitmap as a background image for linear layout after scaling. My bitmap's are of size around 500*500 after scaling this am giving as background image of my screen size 1080*1920. I can see image is been stretched. How can i avoid this
Here is my code
Bitmap alteredBitmap = Bitmap.createBitmap(original.getWidth(), original.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(alteredBitmap);
Paint paint = new Paint();
paint.setFilterBitmap(true);
Matrix matrix = new Matrix();
matrix.setScale(1.5f, 1.5f,original.getWidth()/2,original.getHeight()/2);
canvas.drawBitmap(original, matrix, paint);
Drawable d = new BitmapDrawable(context.getResources(), alteredBitmap);
LinearLayout mRootLayout = (LinearLayout)findViewById(R.id.main);
mRootLayout.setBackground(d);
and layout is
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:focusable="false" >