how to swipe only a portion of the layout

余生长醉 提交于 2019-12-04 18:26:58

Well since you'll be using a ViewPager you don't have to think about the region which is swipeable since the height / width of the ViewPager determines this.

Layout example:

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

    <!-- Static content -->
    <LinearLayout
        android:id="@+id/ll_bottom"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:layout_alignParentBottom="true"
        android:background="@color/holo_blue_light"
        android:orientation="vertical" />

    <!-- ViewPager Indicator -->
    <com.viewpagerindicator.LinePageIndicator
        android:id="@+id/view_pager_indicator"
        android:layout_width="fill_parent"
        android:layout_height="20dp"
        android:layout_above="@id/ll_bottom"
        android:background="@color/holo_orange_light"
        app:lineWidth="10dp"
        app:selectedColor="#fff"
        app:strokeWidth="10dp"
        app:unselectedColor="#888888" />

    <!-- ViewPager containing fragments with different views -->
    <android.support.v4.view.ViewPager
        android:id="@+id/view_pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/view_pager_indicator"
        android:layout_alignParentTop="true"
        android:background="@color/holo_red_light" />

</RelativeLayout>

Result:

Explanation: In the blue region you place your static content which doesn't change like the Facebook-Button in your example. The orange region is used by the ViewPagerIndicator and finally the red region is the one of the ViewPager. As previously said only this area is swipeable.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!