Anushka Agarwal
Anushka Agarwal

Reputation: 127

Add imageview above tabs implemented using view pager

I am creating horizontal tab using page viewer.In my main.xml I am setting header and page viewer and in my fragment.xml I am defining table layout.

My main.xml-

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:src="@drawable/header1" />

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="90dp"
        android:layout_alignParentLeft="true" >

        <android.support.v4.view.PagerTabStrip
            android:id="@+id/pager_tab_strip"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#FFFFFF"
            android:paddingBottom="4dp"
            android:paddingTop="4dp"
            android:textColor="#fff" >
        </android.support.v4.view.PagerTabStrip>
    </android.support.v4.view.ViewPager>

</RelativeLayout>

fragment.xml-

<TableLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:stretchColumns="0,1"
    android:id="@+id/main_table" 
    android:layout_weight="1" 
    android:layout_height="wrap_content" 
    android:layout_width="match_parent">
</TableLayout>

enter image description here

I want this header image at the top before tab.How can I achieve this?

enter image description here

I want this type of view.

Upvotes: 0

Views: 1464

Answers (2)

Anushka Agarwal
Anushka Agarwal

Reputation: 127

This can be implemented by adding two lines in MainActivity which is extending FragmentActivity and in which we are setting our tab.

getActionBar().setDisplayShowHomeEnabled(false);
ActionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.image_name));

Upvotes: 1

Sagar Pilkhwal
Sagar Pilkhwal

Reputation: 3993

try using:

getActionBar().setDisplayShowHomeEnabled(false);  // To hide the app icon
ActionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.MyImage));

Upvotes: 0

Related Questions