我对java和.xml编程完全陌生,多亏了stack overflow和许多其他网站,我才能开始使用一个基本的应用程序。我遇到的问题是这样的:我从一个有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>
发布于 2015-04-05 15:08:20
要使您的TextView可滚动,您必须添加以下代码:
yourTextView.setMovementMethod(new ScrollingMovementMethod())请使用上面的代码,让我知道它是如何进行的。
https://stackoverflow.com/questions/5400534
复制相似问题