【问题标题】:how to swipe only a portion of the layout如何只滑动布局的一部分
【发布时间】:2014-07-08 02:50:23
【问题描述】:

我正在使用 Jake Wharton 的 ViewPagerIndicator 库,我正在尝试与 Tinder 和许多最近的 android 应用程序进行相同的浏览(谈论起始屏幕)...我的意思是布局的顶部可滑动,底部较小的部分显示 Fb/Twitter/G+ 登录按钮。

这是我想要的截图:http://i.imgur.com/QK91rBW.png

我已经读过这个Question,但我认为它不能满足我的需要。

你们能帮帮我吗?

【问题讨论】:

    标签: android android-layout viewpagerindicator


    【解决方案1】:

    由于您将使用 ViewPager,因此您不必考虑可滑动的区域,因为 ViewPager 的高度/宽度决定了这一点。

    布局示例:

    <?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>
    

    结果:

    说明:在蓝色区域中放置静态内容,不会像示例中的 Facebook 按钮那样发生变化。橙色区域由 ViewPagerIndicator 使用,最后红色区域是 ViewPager 之一。如前所述,只有这个区域是可滑动的。

    【讨论】:

    • 谢谢 :) 你是救生员!
    猜你喜欢
    • 2014-07-07
    • 2014-11-16
    • 2022-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-07
    • 2015-07-25
    • 2012-05-29
    相关资源
    最近更新 更多