Praveenkumar
Praveenkumar

Reputation: 119

Aligning the image in the Linear Layout

Image

Below is my code:

<LinearLayout
            android:id="@id/header"
            android:background="@color/colorPrimary"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <ImageView
                android:layout_gravity="fill_horizontal"
                android:gravity="fill_horizontal"
                android:layout_width="match_parent"
                android:layout_height="@dimen/viewpager_header_height"
                android:src="@drawable/bgimage"
                />

            <com.interbind.praveeng.recipeapp.widget.SlidingTabLayout
                android:id="@id/tabs"
                android:layout_width="match_parent"
                android:layout_gravity="fill_horizontal"
                android:layout_height="@dimen/tabs_height"/>
        </LinearLayout>

I want the image to fill the full width of Linearlayout.

Upvotes: 2

Views: 67

Answers (2)

Suhas Bachewar
Suhas Bachewar

Reputation: 1230

You need to add scaleType.

<ImageView
    android:layout_gravity="fill_horizontal"
    android:gravity="fill_horizontal"
    android:layout_width="match_parent"
    android:scaleType="fitXY"
    android:layout_height="@dimen/viewpager_header_height"
    android:src="@drawable/bgimage"/>

Upvotes: 1

Vivek Patel
Vivek Patel

Reputation: 419

you can use

<ImageView      
     android:layout_width="fill_parent"
     android:scaleType="fitXY"
     android:layout_height="@dimen/viewpager_header_height"
     android:src="@drawable/bgimage"/> 

good luck

Upvotes: 0

Related Questions