ScrollView 中的 TextView 不滚动 - Android
我对 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>
I'm completely new to java and .xml programing, and thanks to stack overflow and many other sites, I've been able to get a basic app started. The problem I'm having is this: I started with a tabbed layout with 4 tabs, and simple textviews with 3-4 pages of text in each tab. When I ran this on an emulator, I found the text wasn't scrolling, so after researching for a while, I figured that I needed a ScrollView in order to see all the text. I've now added the ScrollView, but only the first tab is scrolling. I've been looking all over for an answer, and can't seem to find one. I'm just hoping someone can look at my code, and perhaps see where I went wrong.
<?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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要使您的 TextView 可滚动,您必须添加以下代码:
请使用上面的代码并让我知道它是如何进行的。
To make your TextView scrollable, you have to add the following code:
Please use the above code and let me know how it goes.