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.
Related
I have a large layout inside a ScrollView. There are a few EditTexts Which have maxHeight set to 100dp.
The problem is when I copy and past a long text into my EditText the height of it does not increase from maxHeight (which is normal), but the parent ScrollView scrolls to the end. It seems that ScrollView does not understand the maxHeight attribute of the EditText and behaves like there is no maxHeight and EditText has increased its height to wrap the content of the pasted long text.
It seems this issue is fixed on Android 7+, but on older versions this problem exists.
There is nothing interesting in my layout so I will not put it here. It is just a ScrollView which has a vertical LinearLayout inside, and LinearLayout has a bunch of views and a few EditTexts like the following:
<EditText
android:id="#+id/layout_free_text_et"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="48dp"
android:maxHeight="100dp"
android:paddingStart="15dp"
android:paddingEnd="15dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:background="#drawable/section_background"
android:textColor="#color/white"
android:textColorHint="#color/gray"
android:textSize="#dimen/section_text_size"
android:hint="#string/hint_free_text"/>
I have tried to add different attributes to EditText, like maxLine etc. seems nothing solves the issue. I googled a lot, but there is nothing even similar to this issue anywhere. Can anybody suggest me a solution to this problem?
you can use this android:lines="2" it also makes you can scroll the EditText
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"
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.
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.
<EditText
android:id="#+id/textbox"
android:singleLine="true"
android:scrollbars="horizontal"
android:scrollHorizontally="true" />
((EditText)findViewById(R.id.display)).setKeyListener(null);
the EditText serves as some kind of log box, text is appended to it at some events.
I need the EditText to be scrolled to the right at all times, I mean the scrollbar should be positioned to the maximum right and so the most recent text is visible.
I cant seem to get it done, not sure how to read the current position of the scrollbar and adjust it accordingly.
I've tried playing with EditText.setScrollX() though even setScrollX(10000) didnt have any effect.
try with
editText.setSelection(editText.getText().length()-1);