Vinoth
Vinoth

Reputation: 1349

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?

enter image description here

Upvotes: 1

Views: 879

Answers (1)

Jarno Argillander
Jarno Argillander

Reputation: 5945

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.

Upvotes: 2

Related Questions