Tag: android-viewpager

Dynamically set ViewPager height

I am trying to put a ViewPager with different fragments with different heights. I know that wrap_content is not working with ViewPager so I am trying to set pager height dinamically. I am setting the pager height in a page listener: … indicator.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int selected) { final View view = […]

Android swiping, using ViewPager without tabs

Im trying to make an app that have the navigation type of swiping. This is how far I have gone: Fragment activity: package com.app.BoomBase; import android.os.Bundle; import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; public class Fragment_control extends Fragment { String tag = this.getClass().getSimpleName(); @Override public void onCreate(Bundle savedInstanceState) { Log.i(tag, “onCreate”); super.onCreate(savedInstanceState); […]

Make ViewPager snap with shorter drag

Is there any way to make the support package ViewPager snap to the next page with a shorter drag? The default behaviour seems to be that even if I drag almost 75% the page still snaps back to the previous page when I let go. I’d like to make the snap threshold shorter and make […]

Align the child views in center of the ViewPager android

I need to set the child view as center of the ViewPager and also I would like to show some part of the next and previous views to the current view sides(like current screen below 1). But currently the current view is starting at left side of the ViewPager(like expected screen below 2). How can […]

How do I get the child View of a ViewPager at a given item

I’ll keep the question as short and simple as humanly possible. View activeView = mViewPager.getChildAt(mViewPager.getCurrentItem()); returns the child view when the current item is 0 and 1. But if the current item is 2 it returns null . Why is that? edit: Let me rephrase myself. How do I get the child View of a […]

How to customise the CirclePageIndicator?

I am using ViewPager and PagerAdapter to get a slideshow of XMLs in android app. I am using CirclePageIndicator to number the page. How can I customise the color of the circle corresponding to current page ?

ViewPager of Fragment does not show its content when the root Fragment is replaced again

i’m implementing the fragment screen that contains root view pager which contains child fragment and the first of child fragment has a view pager which shows images. it is shown pretty good at first time, but when the fragment which contains root view pager is removed and replaced again (with new keyword for fragment screen), […]

Button in ViewPager scroll to specific page

One of my layouts inside of my ViewPager has a button. “R.layout.add_site”. I would like the option of hitting the button and it scroll to the specific page for me. I already have the option to swipe to the specific page, but I would like to have both. Now I’m sure there’s a way to […]

IllegalStateException: Can't change tag of fragment was android:switcher now android:switcher

My activity uses TabLayout + ViewPager. 3 static tabs + static 3 fragments are initiated when the activity is created. After that, my app fetches some remote objects and render extra tabs + fragments upon receiving those remote objects. At all times, the 3 initial tabs + fragments are the first followed by the dynamic […]

ViewPager in CoordinatorLayout shrinks unexpectedly

In my Android app running on Android 5.1.1 I have a layout using a Toolbar with a TabLayout, and underneath is a ViewPager. All of these are put together in a CoordinatorLayout. In the first page of the ViewPager is a RecyclerView serving CardView items. My problem is that my ViewPager keeps getting resized in […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.