I want to display a list without scrolling vertically. if list height greater than the parent list must start from the next column. if column fit to the parent it must scroll horizontally. Image shows what I want. please help me to solve this problem
In that case you can use a constraint layout. But the logic to break the list should be implemented by you when binding the adapter with the data and view. Recycler view will be a good container. I hope this sheds some light.
Related
I need to show images in horizontal RecyclerView, and this RecyclerView is inside a row of RecyclerView. Now sometimes I receive 2 or 3 images and sometimes more that can fit in its width. So, i want it to be Scrollable when there are more items then its width and when it lists few items then i want empty area to be clickable as well. How can i achieve this behavior?
The problem i am having is concerned in first row where the area need to be clickable is not in my control.
I know, This is old question. But I was stumbled upon a similar scenario.
Place the recycler view inside card view (card view is actually a frame layout) and set the recycler view width to wrap_content instead of match_parent. and the card view (parent of the recycler) width to match_parent. This will give you the expected result.
The card view is required, if you want to have the elevated cards for wrapping the recycler view. Otherwise any ViewGroup (like LinearLayout,Framelayout) should work.
You'll need to add a custom GridlayoutManager. Check this https://gist.github.com/ArthurSav/5f80e19d9ba6d562fbd5
from Arthur's Answer
I apologize beforehand, I do not have any code examples as I am completely in the dark for the solution to my problem. I want to know, how can I scroll the last item of a list to the top position of the recycler view?
By default, if all items are displaying, and scrolling is not necessary, then you can no longer scroll to see more items. The conflict with this is that I am updating information on a separate view based upon the top most item.
Any ideas for this? The only thing I could think of was to add arbitrary, fake empty data so that I can continue scrolling. Thanks in advance
UPDATE: The best alternative solution other than dummy data is to add padding to the RecyclerView. If I add paddingBottom, you do not see the empty space until you scroll to the last item. But the padding has to be precise to force the last item to the top position. So even this is flawed.
<android.support.v7.widget.RecyclerView
android:clipToPadding="false"
android:paddingBottom="300dp"
android:id="#+id/rv_data"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#null"
android:scrollingCache="false"/>
Ok, I was able to get this to work. First I measure the size of the item in the adapter in onBindViewHolder
holder.llWrapper.measure(0,0);
I getMeasuredHeight() from that and pass that back from my Adapter to my Fragment. I then measure the recycler view height. I subtract the height of the recyclerview and the item and the remainder is the amount of padding I need to set bottom to the recyclerview
rv.setPadding(0,0,0,padding);
This is the best I can come up with. Cheers!
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:
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
ListView content being added at bottom instead of top
I'm using ListView to display a list of data elements. Previously the height was set to wrap_content and it was working fine but with few performance lags. Then I came across a blog saying ListView's height should not be set to wrap_content for good performance. After doing this, i.e. setting height to fill_parent, all of my data rows started appearing at bottom of the ListView instead of top. Can any body point to what possibly I'm missing. Thanks in advance.
add this attrubut to your list view android:stackFromBottom="false"