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 horizontal and not vertical when I run the app on the device. At first, I put the image in the drawable-hdpi directory and later in drawable-mdpi, drawable-xhdpi and drawable-xxhdpi directories but I am getting the same result.

How can I fix it?

xml file

<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>
Cœur
  • 37,241
  • 25
  • 195
  • 267
Mr Asker
  • 2,300
  • 11
  • 31
  • 56

3 Answers3

0

LinearLayout it's for oriented children not for background image. This post enter link description here

can help you

Community
  • 1
  • 1
0

please change the orientation of your image using photoshop/paint or any other image editing software. then replace it with the old image.

Note: android:orientation="vertical"

is not to change/ rotate the screen!! orientation property of LinearLayout is defining the alignment of its child components. That means, if you add an ImageView and a TextView, the TextView will be added after the ImageView. Components will be added vertically.

If you need to change the orientation you go through layout for different screens.

and, the drawable-hdpi, mdpi, xxhdpi etc.. are to keep images depending on the device. The device will render images from any of the folder depending on its screen resolution. please read the above link at developer site, it is clear.

Blue_Alien
  • 2,148
  • 2
  • 25
  • 29
0

This works for me:

<?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:scaleType="centerCrop" />

</FrameLayout>

</RelativeLayout>
Mr Asker
  • 2,300
  • 11
  • 31
  • 56