簡體   English   中英

在Viewpager中垂直滾動

[英]Vertical Scroll in 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"

這樣一來,您可以在頂部使用“提交”按鈕和文本視圖,並在其下方具有cn和si按鈕並且可以滾動。 如果要在頂部的cn&si按鈕,在第二種相對布局中,更改

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

至於第二個文件,我不知道viewpager是否具有默認滾動,因此您可能只需要將其包裝在scrollview中即可。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM