2

I've a Image 1280 x 853 in drawables directory. I want to crop that Image at the center using the Screen Size.

That's the way i get the Screen Size:

    DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    int height = displayMetrics.heightPixels;
    int width = displayMetrics.widthPixels;

I thought it would be easy to pick the center of that Image and go half of screen width to left and the other half to the right. I just don't know how to do that.

After I've cropped that Image i want to load it as Splashscreen Background.

I hope my reasoning is clear.

EDIT:

<ImageView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/imageView"
    android:background="@drawable/taskreport_splashscreen"
    android:scaleType="centerCrop"/>
korunos
  • 768
  • 3
  • 11
  • 31

1 Answers1

2

add this property in your ImageView

android:scaleType="centerCrop"
Vishwajit Palankar
  • 3,033
  • 3
  • 28
  • 48
  • Is this the right solution for my Problem? because my Image is to wide, the Image get squished...thats why i want to crop just the center of that image – korunos Jul 16 '15 at 11:45
  • I've added the xml layout of that ImageView. It still is squished :/ – korunos Jul 16 '15 at 11:53