1

I'm using Jake Wharton's ViewPagerIndicator widget to allow the user to swipe between a couple of different views. It's working great. The problem I'm having is that I want to float the indicator widget (in this case the CirclePageIndicator) over the ViewPager, instead of having it appear as a block element above (or below) the actual content (There's a full-screen background image on the content within my viewpager content, and I want the indicator to float over this as well, instead of creating a strip above the content).

Here's the RelativeLayout that doesn't work. I'd just expect the elements to stack on top of each other (indicator on top of the viewpager). If I replace the RelativeLayout with LinearLayout (android:orientation="vertical"), the indicator reappears, but above the content.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <com.viewpagerindicator.CirclePageIndicator
        android:id="@+id/indicator"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

    <android.support.v4.view.ViewPager
        android:id="@+android:id/viewpager"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"  />

</RelativeLayout>

How do I alter my existing code to get the effect I'm after?

noizy
  • 152
  • 2
  • 12
  • 1
    "I've tried using RelativeLayout to get the effect I'm after, but the viewpagerindicator just disappears as soon as I veer away from using the LinearLayout" -- then rather than pasting into your question a layout that you know is not what you want, why didn't you paste into your question the layout that should give you what you want (based on `RelativeLayout`) and is not working? We cannot help you fix your `RelativeLayout` implementation without knowing what it is. – CommonsWare Nov 20 '13 at 20:59
  • It's pretty much exactly the same, with RelativeLayout replacing the LinearLayout tags. But yes, updated... – noizy Nov 20 '13 at 21:03
  • 1
    You're probably looking for this: http://stackoverflow.com/questions/2614393/defining-z-order-of-views-of-relativelayout-in-android – GreyBeardedGeek Nov 20 '13 at 21:06

1 Answers1

4

Swap the order of your CirclePageIndicator and your ViewPager in the XML. Items later in the xml have higher z-order, so you currently have the ViewPager on top.

GreyBeardedGeek
  • 29,460
  • 2
  • 47
  • 67
  • Brilliant. Thanks (also needed to take off the background color on the indicator, didn't I!) – noizy Nov 20 '13 at 21:21