简体   繁体   English

如何在viewpager中使其中一个textViews可滚动?

[英]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. 我的ViewPager工作正常,但是当文本对于页面来说太长时,我无法使textView滚动。 Here is my xml for the layout of each page. 这是我每个页面布局的xml。 I would like the top TextView to stay fixed, while the bottom TextView scrolled if it was too long for the page. 我希望顶部的TextView保持固定,而底部的TextView如果页面太长则滚动。 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 您可以使用ScrollView包裹TextView

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使我的 Horizo​​ntalBarChart 可滚动? - How can I make my HorizontalBarChart scrollable? 如何使FloatingActionsMenu后面的RecyclerView完全可滚动? - How can I make my RecyclerView behind a FloatingActionsMenu fully scrollable? 如何使图像可滚动? [Android平台] - How can I make my image scrollable? [Android Platform] 如何使 flutter 中的 ListView 可滚动? - How can I make my ListView in flutter scrollable? 如何通过Viewpager的setCurrentItem方法使箭头不可见? - How can I make my arrows invisible by setCurrentItem method of Viewpager? 如何使我的按钮在Fragments,ViewPager中执行某些操作 - How can I make my button to do something in Fragments,ViewPager 我如何使按钮可滚动? - How would I make my buttons scrollable? 如何将主要活动中的搜索视图中的信息发送到viewpager中的片段之一 - How can I send information from my searchview in my main actiity to one of the fragments from my viewpager 如何参考屏幕尺寸排列textViews? - how can I arrange my textViews with reference to screen size? 在Eclipse中,如果最小SDK为10,我可以使布局可滚动吗? - In Eclipse, can I make the layout scrollable if my minimum SDK is 10?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM