dOps
dOps

Reputation: 730

Android: ViewPager inside a layout

I have an activity that has a LinearLayout which in turn is split in three more LinearLayouts .

I want to make the top-third horizontally 'swipable'. The solution I assume to make a view swipable is to implement ViewPagers. I am not able to figure out how to get a ViewPager inside a LinearLayout. Also I would rather NOT have tabs on top of each view inside ViewPager.

Upvotes: 0

Views: 1978

Answers (2)

Kunal S. Kushwah
Kunal S. Kushwah

Reputation: 893

My solution will be to use a ViewFlipper:

<LinearLayout ... >
<ViewFlipper>
<RelativeLayout>
<!-- your design here (part1)-->
</Relativelayout>
<RelativeLayout (redifine with same id)>
<!-- your design (part2)-->
</RelativeLayout>
<!--repeat for further parts of your design-->
</ViewFlipper>

</LinearLayout>

Upvotes: 2

Karakuri
Karakuri

Reputation: 38585

I am not able to figure out how to get a ViewPager inside a LinearLayout

Same way you get anythign else into a LinearLayout.

<LinearLayout ... >
    <android.support.v4.view.ViewPager ... />
    <!-- other children -->
</LinearLayout>

It won't have tabs on top since those are not part of ViewPager itself. I recommend spending time looking at the ViewPager docs.

Upvotes: 0

Related Questions