简体   繁体   中英

How can I make one of my textViews scrollable in my viewpager?

My ViewPager is working, but I can't get the textView to scroll when the text is too long for the page. Here is my xml for the layout of each page. I would like the top TextView to stay fixed, while the bottom TextView scrolled if it was too long for the page. Any help is appreciated.

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

You can wrap your TextView with ScrollView like

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM