首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >除非有链接,否则TextView不会垂直滚动

问除非有链接,否则TextView不会垂直滚动
EN

Stack Overflow用户
提问于 2012-04-16 03:35:09
回答 2查看 1.2K关注 0票数 1

我在TextView中启用了垂直滚动,该滚动位于ScrollView中(目的是在水平滚动时将其他内容保留在顶部)--但是,垂直滚动只有在TextView的数据中有链接时才能工作。如果没有url/email/etc,那么垂直滚动就不能工作了。

当它工作时,垂直滚动条也报告错误的滚动位置-在视图中滚动100%,它将转到屏幕的最大5%。

有问题的xml布局给出了这种奇怪的行为,newsreader_message是我希望能够正确滚动的一个:

代码语言:javascript
复制
<?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需要滚动)。

EN

回答 2

Stack Overflow用户

发布于 2012-04-16 03:39:44

将文本视图的layout_width更改为"fill_parent“并尝试一次

票数 0
EN

Stack Overflow用户

发布于 2012-04-16 03:58:58

ScrollViews布局应该是wrap_content .Another选项,让滚动视图进行滚动,文本视图填充空格如下

代码语言:javascript
复制
<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> 
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10168429

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档