android - Viewpager 中的垂直滚动

标签 android scroll android-viewpager

这里我有两个文件。我想在 viewpager 中启用垂直滚动。页面内容超出页面大小。即使内容超过页面大小......我也没有滚动。请帮助。

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

     android:layout_width="match_parent"
     android:layout_height="wrap_content">
    <RelativeLayout      
      android:id="@+id/secAct1"
    android:layout_height="25dip"
    android:layout_width="match_parent"
    android:background="#000000"
    android:layout_alignParentBottom="true"
        >
          <TextView 
        android:id="@+id/cn1"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_alignParentLeft="true"
        android:paddingLeft="10dip"
        android:textColor="@color/white"
        android:textSize="15sp"
        android:text="cn"
        />
      <TextView 
        android:id="@+id/si1"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:paddingRight="10dip"
        android:layout_alignParentRight="true"
         android:textColor="@color/white"
        android:textSize="15sp"
         android:text="si"
        />
    </RelativeLayout>
    <LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/secAct1"
    android:orientation="vertical"
    android:gravity="center"
    android:padding="30dip">
    <Button 
    android:id="@+id/submitAll"    
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"   
    android:text="Submit Responses"    
    />   
    <TextView 
    android:id="@+id/lp"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"   
    android:textColor="@color/white"
    android:text="Thank you for your valuable responses!\n On submitting, you will not be able to changes your                            responses.\nYou responses will be uploaded when your device is connected to the internet.\nThank you for your     valuable responses!\n On submitting, you will not be able to changes your responses.\nYou responses will be uploaded when your device is connected to the internet.Thank you for your valuable responses!\n On submitting, you will not be able to changes your responses.\nYou responses will be uploaded when your device is connected to the internet.Thank you for your valuable responses!\n On submitting, you will not be able to changes your responses.\nYou responses will be uploaded when your device is connected to the internet.\nThank you for your valuable responses!\n On submitting, you will not be able to changes your responses.\nYou responses will be uploaded when your device is connected to the internet.Thank you for your valuable responses!\n On submitting, you will not be able to changes your responses.\nYou responses will be uploaded when your device is connected to the internet.Thank you for your valuable responses!\n On submitting, you will not be able to changes your responses.\nYou responses will be uploaded when your device is connected to the internet.\nThank you for your valuable responses!\n On submitting, you will not be able to changes your responses.\nYou responses will be uploaded when your device is connected to the internet.Thank you for your valuable responses!\n On submitting, you will not be able to changes your responses.\nYou responses will be uploaded when your device is connected to the internet.Thank you for your valuable responses!\n On submitting, you will not be able to changes your responses.\nYou responses will be uploaded when your device is connected to the internet.\nThank you for your valuable responses!\n On submitting, you will not be able to changes your responses.\nYou responses will be uploaded when your device is connected to the internet.Thank you for your valuable responses!\n On submitting, you will not be able to changes your responses.\nYou responses will be uploaded when your device is connected to the internet."
      >
         </TextView>


        </LinearLayout>
           </RelativeLayout></ScrollView>  

下一个文件

    <?xml version="1.0" encoding="utf-8"?>

    <LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/fragQue"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
     >

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

        android:background="@drawable/radialback"
        >
    <android.support.v4.view.PagerTabStrip
            android:id="@+id/pager_title_strip"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="top"
            android:paddingTop="@dimen/fQ_P"
            android:paddingBottom="@dimen/fQ_P" 
            android:background="@color/yellow"
            android:textColor="@color/textGray" 
             /> 
    </android.support.v4.view.ViewPager > 

    </LinearLayout>

最佳答案

首先,您拥有它以便 TextView 位于 cn 和 si 按钮上方,即使按钮位于屏幕底部,它也无法按照您希望的方式工作。

android:layout_above="@+id/secAct1"
//should be
android:layout_below="@+id/secAct1"

这将为您提供顶部的提交按钮和 TextView ,以及下方的 cn 和 si 按钮,并且可以滚动。 如果你想要顶部的 cn 和 si 按钮,在第二个相对布局中,更改

android:layout_alignParentBottom="true"
//to
android:layout_alignParentTop="true"

至于第二个文件,我不知道 viewpager 是否有默认滚动条,所以你可能只需要将它包装在 ScrollView 中即可。

关于android - Viewpager 中的垂直滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14465304/

相关文章:

java - 在 Android 中选择项目后如何关闭弹出 ListView

javascript - jQuery 的平滑滚动在我的网站上不起作用

C# 在拖放时在 ListView 中实现自动滚动

iphone - Cocos2d滚动游戏TileMap碰撞

android - popBackStack 后 ViewPager 中的 fragment 不显示

java - ViewPager fragment 随着时间的推移而被破坏?

android - 内存不足+位图+ImageView+ViewPager

android - 警报对话框生成器 : No items for checkboxes are shown

android - 我可以保留依赖项使用的旧版本库吗?

android - Gradle 中的 Mockwebserver 构建抛出错误