Home » Android » scroll – Non scrollable textview in android

scroll – Non scrollable textview in android

Posted by: admin June 15, 2020 Leave a comment

Questions:

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.

How to&Answers:

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

may be this is solution for you

Answer:

Try changing ‘Relative Layout’ to ‘Table layout’… If this doesn’t work then try to set appropriate padding and margin for Textview and other widgets.