footer is fixed on viewpager in android -


i have footer using viewpager. when swipe left or right footer swipe left or right. want footer fixed on each page on viewpager. idea make footer stay fixed when swipe pages.

you have create master layout. has viewpager , footer , load fragments view pager.

<?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">     <!--header-->     <textview         android:id="@+id/headertextviewe"         android:layout_height="50dp"         android:layout_width="match_parent"         android:text="header"         android:textcolor="@android:color/black"         android:textsize="24dip"         android:typeface="sans"         android:layout_gravity="center"         android:layout_centerhorizontal="true"         android:background="@color/background"         android:gravity="center" /> <!--view pager-->     <android.support.v4.view.viewpager         android:id="@+id/createteamviewpager"         android:layout_width="match_parent"         android:layout_height="420dp" />     <!--footer-->        <button         android:text="next"         android:layout_height="50dp"         android:layout_width="match_parent"         android:id="@+id/nextbutton"         android:textstyle="bold"         android:textsize="17sp"         android:hint="next" /> </linearlayout> 

activity:

public class mymatches extends appcompatactivity {     private toolbar toolbar;     private tablayout tablayout;     private viewpager viewpager;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_my_teams_master);     iniui();     setupviewpager(viewpager); } 

`

void iniui() {     toolbar = (toolbar) findviewbyid(r.id.toolbar);     setsupportactionbar(toolbar);     getsupportactionbar().setdisplayhomeasupenabled(true);     viewpager = (viewpager) findviewbyid(r.id.viewpager);     tablayout = (tablayout) findviewbyid(r.id.tabs); } void setupviewpager(viewpager viewpager) {     customviewpagerfragmentadapter adapter = new customviewpagerfragmentadapter(getsupportfragmentmanager());      customlistviewfragment fragment1= customlistviewfragment.newinstance();     customlistviewfragment fragment2= customlistviewfragment.newinstance();     adapter.addfragment(fragment1, "current");     adapter.addfragment(fragment2, "past");     viewpager.setadapter(adapter);     tablayout.setupwithviewpager(viewpager);     getsupportactionbar().settitle(getresources().getstring(r.string.mymatchesitem));     //toolbar.settitle(getresources().getstring(r.string.mymatchesactivitytitle));     toolbar.setnavigationonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {             activitycompat.finishaftertransition(mymatches.this);         }     }); } 

}


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -