0

I am making an image with my s4 Samsung device which I am trying to put as splash image for my app but I am facing problem that the Image is being displayed with wide white space Frame. How can I remove it?

XML file:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout       
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<FrameLayout
    android:id="@+id/fl_draw"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/splash_background"
        android:rotation="90"
        android:adjustViewBounds="true" />

</FrameLayout>

</RelativeLayout>

I have displayed the Image in LinearLayout as the code below before but it was shown horozintal:

Code before:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" 
     android:background= "@drawable/splash_background"
    >

</LinearLayout> 

Screenshot before trying the solution of Hasan:

enter image description here

After trying hassan solution android:scaleType="centerCrop"

enter image description here

MrPencil
  • 934
  • 8
  • 17
  • 36

1 Answers1

1
<ImageView
    android:id="@+id/imageView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:src="@drawable/splash_background"
    android:scaleType="centerCrop" />

Any graphical designer while working on a mobile app. should take in consideration the mobile development guide lines.

When designing a splash screen image the designer have two solutions:

  1. produce an image that have a solid background or transparent with no gradient. in this case the image can be displayed in the centre with a background color.

  2. produce an image that doesn't look ugly when it's cropped from top/bottom or left/right(depends on screen ratio). in this case you use centerCrop as scaleType.

hasan
  • 23,815
  • 10
  • 63
  • 101