Recycler View Scroll to middle of screen - android

Hello I am not sure if this would be a duplicate as my wording is probably not the best to describe this on a search. I have a recycler view with a list of strings. Everything works great however, is there a way to make the list scroll a little higher than the bottom of the parent view, in this case keep scrolling up until it hits the middle of the screen? the Recycler view would height is match parent. Thank you in advance!!
Please note: I didnt add code since this is just a regular recycler view nothing special added, let me know if the code is needed as well thank you!
Edit:
this is for a vertical scroll list only. The following images are some list images I got offline but hopefully they can show better what I am trying to accomplish:
I want to be able to scroll the list up to the middle as in the following picture for example:

Related

Horizontalscroll view UI breakdown

I am trying to make a horizontal scroll just like the one showed image below, I have a horizontal scroll view here but how is it focusing on a single item in list when I scroll(I am asking about the sort of forward effect of middle one)
Thanks!
Her's the link which may help you https://github.com/blessenm/AndroidAutoScrollListView

Scroll text inside recyclerview element

I have a recyerview which contains in each row a picture, a title and a description.See here.
The height of an element of the recyclerview is fixed.
The problem is the description could be too long for the fixed height.
To solve it I would like to implement a vertical scrolling that could allow me to read everything in any cases.
I have no idea where I have to search to do that.
Someone has a good tutorial to follow ?
Thank you.
As far as I know, you will get scroll conflicts by doing this as the recyclerview will not know whether to scroll itself upwards or to scroll the actual text inside it's views.
A better approach is to implement an expandable textview, an easy to use library can be found here:
https://github.com/Manabu-GT/ExpandableTextView

How do I dynamically add a background view to Recycler list view item?

I'm using cards to show a list in a recycler view and have implemented Swipe-To-Show-Background feature. But I'm struggling to figure out how to dynamically add a view underneath the card which doesn't get moved but gets displayed when the top view item gets moved?
I can't obviously have the back-view and front-view in the same card, as they both will get swiped.
Edit:
So, I've a card view that has swipe left/right feature. I want to show a view in its background when swiped right. My biggest issue here is I'm not able to dynamically add a view and make it visible when the card is swiped.
I don't have enough reputation to comment so i am posting this as answer.
Firstly, please elaborate your question properly it is a bit vague. Meanwhile, to change background dynamically you can try setBackgroundResource(R.drawable.xxx)

Listview with column flow

I want to add views to Horizontal listview (custom). The way i want to add them is:
Add a view (all views will be of width screenWidth/2) at top left of
the screen.
Add next view below that view.
Keep adding till the bottom of the screen is reached. When there is
no space for another view to sit, start adding to a new "column".
I have achieved this with a simple LinearLayout, now i am not getting any ideas how to do it with a ListView. The reason behind choosing a list view is that my app might contain thousands of such child views, and list view helps in keeping only those views i nmemory that are currerly needed.
Any help is appreciated guys.
You'll need to place GridView in HorisontalScrollView and sweat a bit to make it work. See here

Scrolling issues with GridView in Android

I am having weird scrolling issues in my pretty simple GridView. Each item in the Grid is simply an ImageView and a TextView. The activity itself is simply an application selector. It looks like a rough version of the basic App Tray in Android.
The issue is that after spending some times scrolling through my view, it will inevitably allow me to continue scrolling past the top row of icons, to a blank screen, and the scroll bar will disappear, leaving me stuck.
It doesn't happen every time I go to the top of the view, only sometimes, and usually only after some excessive scrolling.
If I happen to notice the problem and catch it before the top row disappears off the bottom of the screen, I can usually scroll back through the view and spot some icons missing. There are empty spaces in the grid, and I can only assume that those icons have been moved to some bizarre position, which is allowing the view to scroll past the top.
This is my first Android app beyond a basic Hello World, so it's likely that I've just screwed up something in my layout files. I also realize that this is probably a pretty confusing description, so I'm hoping someone has experienced this and my search abilities simply were unable to find it.
I can post my layout files or other code if someone thinks that's useful.
Oh, and the program is built against 1.5, but is running on 2.2 (whatever state of 2.2 that was that snuck out last week) on my phone. I don't have enough apps to test this on an emulator, but could probably set something up if someone felt it necessary.
Thanks in advance for any help on the issue.
I had same problem, but I post to GridView only ImageView's so pengwang's answer didn't help me. I found explanation for this bug https://code.google.com/p/android/issues/detail?id=16218
The problem is that GridView does not currently handle items with differing heights.
My solution is to use exactly specified layout_height same for all GridView's items.
i have solved it: in the link GridView cannot show image you can try
It seems that if you scroll off the bottom of the GridView and back again very fast a couple of times, you eventually will notice that the elements of the view get shifted one place to the "left" from where they originally were. When this happens, you then can scroll all the way off the top of the GridView. When you do reach the top of the list, item 0 is not displayed, having item 1 in its place and nothing but blackness above that row.
Clicking on any item in this situation resets the list and everything is back to normal.
This must be a bug. It's highly reproducible, and I don't think anything I'm doing is causing the mix up. At this point, adding to the list adapter has stopped.
Right now I'm working with Android 2.3.3.
I just ran into this exact same issue myself -- I have a grid of images that have different heights. After reading the Android developer's doc on GridView, GridView.LayoutParams and GridLayout, I did two things that fix my issue:
find the tallest image in each row, and store the height in a map of row -> rowHeight. Each image that I download has width and height info, so this is easy for me to do by overriding my adapter's addAll(items) method.
in getView(), I create a GridView.LayoutParams(MATCH_PARENT, getRowHeight(position)), which sets each grid item to the max row height for its specific row.
wrap my ImageView inside a LinearLayout. I have tried other layout but LinearLayout is the one that works. Set android:scaleType="fitCenter" and android:adjustViewBounds="true" for the image view.
After above 3 steps I finally got the grid to look right, they have different heights, and there's no scrolling issues.
I had a similar, but probably less common problem, where just scrolling a little bit would scroll the gridview to the end and I was not able to scroll up at all. This only occurred when the gridview was smaller, for example when the keyboard was visible. The problem was that I used:
android:paddingBottom="400dp"
android:clipToPadding="false"
Making padding bottom much smaller fixed my issue. I hope this helps at least someone!

Categories

Resources