我有一个页脚,我正在使用它与viewpager一起。当我向左或向右滑动时,页脚也会向左或向右滑动。我希望页脚在每个viewpager页面上都保持固定。有什么想法可以使页脚保持固定,即使我滑动页面。
我有一个页脚,我正在使用它与viewpager一起。当我向左或向右滑动时,页脚也会向左或向右滑动。我希望页脚在每个viewpager页面上都保持固定。有什么想法可以使页脚保持固定,即使我滑动页面。
<?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>
活动:
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);
}
});
}
}