TextView в ScrollView не прокрутка - Android

1

Я полностью новичок в программировании java и .xml, и благодаря переполнению стека и множеству других сайтов я смог запустить базовое приложение. Проблема, с которой я столкнулась, такова: я начал с вкладок с вкладками с 4 вкладками и простым текстовым просмотром с 3-4 страницами текста на каждой вкладке. Когда я запускал это на эмуляторе, я обнаружил, что текст не прокручивается, поэтому, проведя некоторое исследование, я подумал, что мне нужен ScrollView, чтобы увидеть весь текст. Теперь я добавил ScrollView, но только первая вкладка - прокрутка. Я искал ответы на все вопросы и не могу найти его. Я просто надеюсь, что кто-то сможет посмотреть мой код и, возможно, посмотреть, где я ошибся.

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <ScrollView
            android:id="@+id/ScrollView01"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
        <TextView
            android:id="@+id/textview1"                
            android:text="3-4 pages of text here"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:lineSpacingExtra= "5sp"
            android:background="@color/backgroundColor" 
            android:textColor="@color/textColor"/>
            </ScrollView>                
            <ScrollView
                android:id="@+id/ScrollView02"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent">
        <TextView
            android:id="@+id/textview2"                
            android:text="3-4 pages of text here"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:lineSpacingExtra= "5sp"
            android:background="@color/backgroundColor"                                
            android:textColor="@color/textColor"/>
            </ScrollView>                     
            <ScrollView
                android:id="@+id/ScrollView03"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent">  
        <TextView
            android:id="@+id/textview3"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:lineSpacingExtra= "5sp"
            android:text="more text in here" 
            android:background="@color/backgroundColor" 
            android:textColor="@color/textColor"/>
            </ScrollView>                    
            <ScrollView
                android:id="@+id/ScrollView04"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent">
        <TextView
            android:id="@+id/textview4"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:lineSpacingExtra= "5sp"
            android:text="even more text here"
            android:background="@color/backgroundColor" 
            android:textColor="@color/textColor"/>
            </ScrollView>                               
            />                
</FrameLayout>
</LinearLayout>

Теги:
textview
scrollview
android-tabhost
tabwidget

1 ответ

0

Чтобы сделать свой прокручиваемый текст, вам необходимо добавить следующий код:

    yourTextView.setMovementMethod(new ScrollingMovementMethod())

Пожалуйста, используйте приведенный выше код и дайте мне знать, как это происходит.

Ещё вопросы

Сообщество Overcoder
Наверх
Меню