2016-12-06 25 views
0

我的ViewPager正在工作,但當文本太長時,我無法讓textView滾動頁面。這是我的每個頁面佈局的XML。我希望頂部的TextView保持固定,而如果頁面太長,底部的TextView會滾動。任何幫助表示讚賞。如何讓我的一個textViews在我的viewpager中滾動?

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:padding="10dp" > 

<TextView 
    android:id="@+id/reference" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:textColor="#128238" 
    android:textStyle="bold" 
    android:textSize="24dp"/> 

<TextView 
    android:id="@+id/details" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:textColor="#128238" 
    android:textSize="24dp" 
    android:layout_below="@+id/reference" 
    android:scrollbars="vertical" /> 

回答

1

你可以用你的TextViewScrollView

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" > 
    android:id="@+id/content_main" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 

    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

     <TextView 
      android:id="@+id/device_info" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      tools:text="device info" /> 

    </ScrollView> 

</RelativeLayout> 
+0

對不起,什麼是wttribute - 的命名空間工具的文字?他的工作是什麼? –

+1

xmlns:tools =「http://schemas.android.com/tools」 –

+0

完美!還必須將layout_below行移動到滾動視圖中。 – HGamble

相關問題