我在TextView中启用了垂直滚动,该滚动位于ScrollView中(目的是在水平滚动时将其他内容保留在顶部)--但是,垂直滚动只有在TextView的数据中有链接时才能工作。如果没有url/email/etc,那么垂直滚动就不能工作了。
当它工作时,垂直滚动条也报告错误的滚动位置-在视图中滚动100%,它将转到屏幕的最大5%。
有问题的xml布局给出了这种奇怪的行为,newsreader_message是我希望能够正确滚动的一个:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/newsreader_subjectdate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="1"
android:scrollHorizontally="true"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/newsreader_fromto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="1"
android:scrollHorizontally="true"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall" />
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/newsreader_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoLink="web|email"
android:contentDescription="News post content"
android:keepScreenOn="true"
android:paddingRight="10dp"
android:paddingTop="6dp"
android:scrollHorizontally="true"
android:scrollbars="horizontal|vertical"
android:text=""
android:textSize="11.5sp"
android:typeface="monospace" />
</ScrollView>
另外一个细节是,当垂直滚动中断时,marquees也不会滚动(而且marquees需要滚动)。
发布于 2012-04-16 03:39:44
将文本视图的layout_width更改为"fill_parent“并尝试一次
发布于 2012-04-16 03:58:58
ScrollViews布局应该是wrap_content .Another选项,让滚动视图进行滚动,文本视图填充空格如下
<ScrollView android:id="@+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollHorizontally="true"
android:scrollbars="horizontal|vertical"
android:fillViewport="true" >
<TextView
android:id="@+id/newsreader_message"
android:layout_width=""fill_parent"
android:layout_height="fill_parent"
android:autoLink="web|email"
android:contentDesciption="News post content"
android:keepScreenOn="true"
android:paddingRight="10dp"
android:paddingTop="6dp"
android:text=""
android:textSize="11.5sp"
android:typeface="monospace"
android:layout_weight="1.0" />
</ScrollView> https://stackoverflow.com/questions/10168429
复制相似问题