How to remove vertical image gaps in android - android

I kept my image size as 320*480 but it shows blank space in vertical sides,Please give some advice.Here is my xml code please suggest me..
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="#+id/ImageView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:baselineAlignBottom="true"
android:src="#drawable/splash" />
</LinearLayout>

add attribute android:scaleType="fitXY" to imageview

Related

Image does not fill width in ImageView Android

Setting a photo to an ImageView does not work as i expect. It does not fill the width completely.
This is my code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/black"
android:orientation="horizontal" >
<com.android.volley.toolbox.NetworkImageView
android:id="#+id/imageCell"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:layout_margin="5dp"
android:src="#drawable/unnamed" />
</LinearLayout>
I tried with android:layout_width="wrap_content" and still no change.
The first image is not shown completelly. The second one is in portraid mode and it's ok.
Thank you.
try setting
android:scaleType="fitXY"
to your imageView

Image is displaying in LinearLayout stretched?

I'm having trouble displaying my image within my LinearLayout. I'm trying to get a background color of white and have an ImageView displayed in my LinearLayout and the image and the background color works find, but the image is stretched.
What's a good way to proportion the image show that it displays normal? Any ideas?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#FFFFFF">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<ImageView
android:src="#drawable/day1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageView>
</LinearLayout>
</ScrollView>

android imageview takes extra black space

the imageview takes extra [black] space and i dont know why
ok this imageview should wrap content but instead..
photo explains the problem
this is the code
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="#+id/map"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/map" /><ImageView
android:id="#+id/blxx"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingBottom="-20dp"
android:src="#drawable/photo" />
<ImageView
android:id="#+id/blxx"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="#drawable/blxx" />
</LinearLayout>
</ScrollView>
Try the below:
android:adjustViewBounds="true"
This will remove the extra padded space
first possible reason for your problem:
sometimes when the image is too small, it can't scratch anymore then some limit. after that limit - what happens is what you see - blank space claimed by the imageView where additional scratch of the image was expected. I advice you to take larger picture (with bigger resolution)
Second possible reason:
add to your imageView properties on the xml file the following attribute:
android:scaleType="fitXY"
android:layout_gravity="center"
Above line is centering the image to fit inside your ImageView. Try without it. If not, set gravity to "fill" and try again.
Also remove one of the duplicates of blxx as noted.
hope this ll help you
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_gravity="center">
<ImageView
android:id="#+id/map"
android:layout_width="fill_parent"
android:layout_height="fill_content"
android:src="#drawable/map" />
</LinearLayout>
</ScrollView>

Android Layout - Image taking up extra space

I've added an image to my xml file. This is the code that I am using:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/topbar_logo2x"
android:scaleType="fitStart" />
<TabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<View
android:layout_width="fill_parent"
android:layout_height="0.5dip"
android:background="#000" />
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="0dip"
android:layout_marginRight="0dip" />
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
</TabHost>
</LinearLayout>
I want my TabHost to be exactly on top of my image. When I checked up some answers in StackOverflow, I got an answer that stated to use
android:scaleType="fitStart"
I want to use both android:scaleType="fitStart" and android:scaleType="fitEnd" on the same ImageView and that is not possible as Sndroid will allow only one declaration of scaleType. How will I be able to attain the same with change in code ? Is there some other command that will help me?
Seems to me the larger black line must come from the image (topbar_logo2x) or the way it is scaled into the ImageView. Try using scaleType="fitXY" to see if the above black line vanishes. If not, then post the image for us to look.
Seems to me the View below LinearLayout causes the smaller black line. Remove it.

SplashScreen not stretched

I want to implement a splash screen for my app, i'm using this code to show the image, but the image is centered and not stretched to the whole screen. How can i solve that problem?
Thank you very much.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView android:src="#drawable/splash"
android:id="#+id/splash"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</ImageView>
</RelativeLayout>
Try
<ImageView android:id="#+id/splash" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:src="#drawable/splash"
android:scaleType="fitXY" />
Where android:scaleType="fitXY"is responsible for stretching the image.

Categories

Resources