Android autoscrolling text view - android

I would like to implement a auto scrolling text view in a native Android app.
Something like a vertically scrolling marquee. The idea being that it looks something similar to an autocue, the text will remain static and scroll once more text has been provided.
I am happy to work out the logic of scrolling the text when new text arrives. I am just looking for ideas on how to have that text feed/scroll effect animation.
Thank you

Maybe start here to make the textview scrollable:
Making TextView scrollable on Android
After that, you should be able to use an object animator, such as:
ScrollTo(0,250) with animation Android ScrollView

Do like:
in XML:
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0.0dp"
android:scrollbars="vertical"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:maxLines="5" />
And in java:
textView.setMovementMethod(new ScrollingMovementMethod())

You Just check it and refer this answer.
Android automatic horizontally scrolling TextView
I think you want solution like this. for auto scrolling TextView.
there is many other solutions also which working with programmatic to scroll String in your TextView area.
auto-scrolling TextView in android to bring text into view
Automatic horizontal scroll in TextView
Refer this links and get Solution as per you want.
Thanks for this question's owners and accepted Answer givers.

Related

Why my TextView is Scrolling in android?

Why my TextView is Scrolling?
<TextView
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/rl_logo_header"
android:layout_marginTop="5dp"
android:autoLink="web"
android:descendantFocusability="blocksDescendants"
android:ellipsize="end"
android:focusable="false"
android:maxLines="3"
android:text="Should my school be focused on -- Teaching and Learning come as words which are very closely related, But they convey very different meanings and can not be used interchangeably."
android:textColor="#color/black" />
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 3 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.
autoLink controls whether the TextView will parse URLs and highlight them as such. It has nothing to do with rendering HTML.
Your TextView is scrolling because you've set android:maxLines="3"

Telegram android message cell

I am trying to make a layout like Telegram message box in android.
When the text is short the message and time are aligned in one single line as follows:
But when the message text is longer the time text view is pushed to the bottom of message like this:
How can i achieve this?
P.s. I tried to read the telegram source but wasn't able to figure it out. And i tried to get the size of my text view in adapter but wasn't successful.
Your shown example looks like a RelativeLayout with two TextViews in it (first TextView top-left and second TextView bottom-right).
It should be possible to accomplish this by using a RelativeLayout and two TextViews. The TextViews should be positioned correctly based on the length of the text (the second TextView displaying time should be always in bottom-right corner).
Actually they are not aligned in one line... :D I think you can achieve this by wrapping your TextView for time in RelativeLayout like that:
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#drawable/background"
android:padding="10dp" >
<TextView style="#style/TextView_port"
android:id="#+id/text"
android:text="Text" />
<RelativeLayout style="#style/LinearLayout"
android:layout_below="#id/text"
android:layout_margin="10dp"
android:gravity="right" >
<TextView style="#style/TextView_port"
android:text="3:59pm"
android:textColor="#73B661" />
</RelativeLayout>
</LinearLayout>
Here i found a trick to set your text alignment to justify:
https://dzone.com/articles/android-%E2%80%93-how-display
EDIT
I finally came up with the solution - the edited code above is for short texts. Check programatically the length of the text and if it is more than 20 for example set orientation of the Linear to vertical and only top margin of the time TextView to -20 - I'll update my answer later if you don't know how :)

Android detect and clickable web address in textview

I am working on textview, I want to do that if there is any web link in textview so it will detect that and also clickable. How can I achieve that?
There are two main ways - xml which does most work for you (see #Massimo answer) and code which is very flexible, it allows you to make some text clickable and intercept link clicks (see LinkMovementMethod)
Set the autoLink and linksClickable attributes in your xml's TextView
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:linksClickable="true"
android:autoLink="web"/>

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
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.

Horizontol scrollbar in android text view

I have a expandable list view consisting of varied sized textviews. The TextView size depends upon the contents in it. Now there are certain text which exceeds the screen width and the user is not able to view it.
I have tried HorizontolScrollView inside a ScrollView. It performs the scrolling but as my UI is a bit complex, it doesnot renders the other widgets in the view (like checkbox) properly.
Please suggest some good ideas to do the manual text scrolling.
Marquee is not a good suggestion. :)
Thanks in advance
Nested scroll view is a big 'no no' in android as there is no good way to determine which scroll has focus.
My solution would be to make an non-editable EditText. I would do something like this.
<EditText android:scrollHorizontally="true"
android:editable="false"
android:enabled="false"
android:layout_width="match_parent"
android:id="#+id/editText1"
android:layout_height="wrap_content" >
</EditText>
TextView seems to have a android:scrollHorizontally property as well but I have had no luck getting it to function.

Categories

Resources