Horizontal scrollable Textview which is in listview in Android? - android

I have a Listview in which there are 3-4 textviews. I am using the BaseAdapter way where I am inflating xml. All the textviews are single line. I want to make the textview horizontally scrollable. I have tried to put the textview inside HorizontalScrollview. Well, that did scrolled the textview but then I was not able to get the click event of listview.
Is there any other way I can make the textview scrollable horizontally?

I was able to solve this issue by adding this line to first RelativeLayout in the xml file android:descendantFocusability="blocksDescendants". In this way no child will have focus and so the horizontal scrollbar also works and listview item clicks also works. It worked for me. Anyways, thanks everyone.

AFAIK there is no easy way to do this.
The problem is that scroll view consume all touch events. To solve this one should make sure that horizontal scroll view consume only "horizontal" move events.
First you should implement you own scroll view. Then override onTouchEvent() of that view so it only consume "more horizontal than vertical" gestures and left "vertical" gestures for list view.

You can try to use the ellipsize property of the TextView class. If you set it to marquee the text should automatically scroll when it is focused.

Why don't anybody use TextView.setMovementMethod(ScrollingMovementMethod.getInstance()) with android:scrollHorisontally="true"?

Related

Android: How to do fast scrolling for ScrollView with one TextView like in ListView?

I have to show a log file in a TextView which is within a ScrollView. When the log file is bigger, it is very hard to scroll to the end of the view.
So how can I implement a fast scrolling like in ListView with 'fastScrollEnabled'? ScrollView and TextView does not support fast scroll.
I searched here, but I didnĀ“t find any answer to this question. One hint was to do it yourself, but how?
scrollView.fullScroll(View.FOCUS_DOWN);
Calling this on your ScrollView will scroll the view to the bottom.
If you wish to enable/disable animated scroll transitions, toggle the ScrollView's smooth scrolling property.
scrollView.setSmoothScrollingEnabled(false);

Margin bottom headerview in listview

I'm implementing a listview that looks like this :
So basicly I have a listview, with a headerview. My problem is to set the space between the headerview and the rest of the listview. If anyone has a clue, thanks :)
To set a gap below the header view you can just add marginBottom to the header view. That should do it. But like Pauland said, never ever EVER put a listview inside a scrollview. You are basically placing two vertical-scrolling views ontop of each other and Android can't tell which one to scroll when the user swipes!

scrollView linearlayout and listview

I'm doing an android app, and I just want to have an scrollable layout, but inside of this layout I want to put some textView and 2 listView, and this is my problem, the listView.
I need to include this 2 listview on the layout and this is obligatory need to be scrollable, and I googling and all I found is negative.
how can I put 2 listview on scrollView?? is not possible? and if its right what can i do? Which is the alternative that I have? I really desesperated because I spend all day!!
con someone say me an example of this?
really thanks!
ListViews shouldn't be placed inside a ScrollView because the ListView class implements its own scrolling and it just doesn't receive gestures because they all get handled by the parent ScrollView. However you can add views you want to be scrolled to the ListView as headers or footers.

Scrollview inside listview issue in android

I am adding a listview inside a scrollview in xml that xml(Screen) is loading from the middle screen. In my design I have a top part like a textview and a list view and middle part like editext and bottom part like button. Page is loading from the middle part. If it scrolls I can only see the above part. I want to load the page from above part. Can anybody tell me what the problem is and how to resolve it?
Thanks
Use android:fillViewport="true" as an attribute in your scrollview tag and it will fill up the screen.
Actually there is no need to use ScrollView with ListView. Use ListView only, you will be able to scroll the items in a ListView.
You should never use a ScrollView with a ListView, because ListView
takes care of its own vertical scrolling. Most importantly, doing this
defeats all of the important optimizations in ListView for dealing
with large lists, since it effectively forces the ListView to display
its entire list of items to fill up the infinite container supplied by
ScrollView.
found it here
using smoothScrollTO(0,0) to fix the issue

ExpandableListView affecting the size of Scrollview when collapsing and expanding

Let me try to explain what I want to achieve. Currently, I have a ScrollView as the main view for my layout and a linearLayout within that to place all of my content into.
In my LinearLayout, I have a bunch of textviews and a gallery, which extends out of the screen, so the user can scroll to see everything. It works.
Now, I want to add an expandableListView to the bottom of all that content, which is still in the linearLayout. The problem is when you expand the list view groups it doesn't affect the ScrollView. I had envisaged that when you expand a group it would make the linearLayout bigger, which in turn makes the scrollview bigger.
Is what I'm thinking achievable?
EDIT:
Ok I think the situation is that listViews are normally placed in a layout by themselves and have scrollviews already enabled. You just set it to fill_parent and it works fine. However, in my case, I'll need the expandableListView to display all content without scrolling, because my ScrollView will deal with that. I don't even think it possible?
It's difficult to answert without seeing your layout xml, but I think that if you set the android:layout_height of the linear layout and expandableListView to wrap_content, the first scrollView must scroll the whole view.
have you tried putting your expandable list into another linear layout and than put it in the scroll views default linear layout?

Categories

Resources