android - 如何只滑动布局的一部分

标签 android android-layout viewpagerindicator

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

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

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

你们能帮帮我吗?

最佳答案

因为您将使用 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>

结果:

enter image description here

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

关于android - 如何只滑动布局的一部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24622942/

相关文章:

android - fragment 内的 ViewPager 不起作用

android - 为 Android 构建 MUPDF

java - 地理编码代码不起作用 - Googlemaps

java - 支持多屏(手机和平板)

android - 在 KitKat(4.4) 的横向模式下,导航栏不透明

android - 如何使用 ActionBarSherlock、ViewPagerIndicator 和 SlidingMenu

android - 如何为android构建一个跨平台的html5应用程序

java - 在 Android 中使用图库图像更改图像按钮

android - 这是普通的 Android 通知 (RemoteView) 布局吗?

android - Android 中的触摸或单击事件 ViewPagerIndicator