简体   繁体   中英

Non scrollable textview in android

I have a textview configured in my XML as below.

<RelativeLayout>
   <!-- more views here like ImageView and other TextView-->
    <TextView
        android:id="@+id/message"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:maxLines="4"
        android:textIsSelectable="false"
        android:autoLink="web|phone|email"/>
</RelativeLayout>

The content for this view could be text and may also contain HTML content. Hence I have set autoLink to true. The issue is, if either the autoLink or the textIsSelectable is true, then the textview starts to scroll similar to(MovementMethod) when its content is more than 4 lines. I am looking for a way to stop/disable this textview scrolling.

I tried to disable the scrolling using setEnable(false) for the text view, however, all the links in the textview could not be clicked thereafter.

I think there has to be a straight forward way to achieve "non-scrollable textview" which may contain HTML content in them.

I think you can add the attribute android:nestedScrollingEnabled="false" to any View child. At least, I use android:nestedScrollingEnabled="true" to make my TextViews scrollable. Hope this solves your problem.

BTW, why are you trying to display a clickable link when you can't even scroll to look at the entire link? Just asking out of curiosity.

set ellipsize to the text view so text can't be greater than 4 lines

may be this is solution for you

尝试将“相对布局”更改为“表格布局”...如果这不起作用,请尝试为 Textview 和其他小部件设置适当的填充和边距。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM