ListView background scroll with data - java

Is it possible to make a background stretch over the whole ListView, instead of just staying on a fixed position?
I remember in CSS when making websites you could make the background-attachment fixed for a background to stay the same place when scrolling, I am trying to archive the opposite of this, making the background follow the data when you scroll down. Is there such a thing for ListView?

Using a stock ListView to do what you want would not be possible.
ListView only displays a few rows at a time in order to save on View creation/management/etc. that could bog the system down. As a result, the ListView doesn't even know the total height of itself - it doesn't render a row until that row is visible, and rows can vary in height. If it doesn't even know its own height, how could it have a background that spans the entirety of it?
That said, your idea of using a ScrollView would be possible. However, you would then be losing out on ListView's optimization - if you only had few rows, then this isn't a big deal; but if you're talking about dozens of rows (or more), then your app may seriously chug. Also, you don't get ListView's framework, which is geared towards making an easier row-based UI.
It would be possible to write your own ListView subclass (or custom ListView) that can calculate its total height (so long as you know that each row is of a fixed height), then draw the background accordingly. That is probably what I'd do if I was required to do what you describe and had too many rows to just stuff into a ScrollView comfortably.

Related

How to create a grid which you can scroll both vertically and horizontally, which contains random sized elements, and works with recyclerview?

I am a beginner, and i tried to find an answer but everything i found was from 2013 and earlier. I want to create a grid which you can scroll in any direction, (as a zoomed in picture), which contains items of different sizes which are generated randomly, then i want to populate them with a recycler view. I will attach an illustration, maybe you would understand it better.As you can see, the thick outline is the phone screen and whenever you scroll the view, it generates new items which are populated by a recycler view.
I thought of using Google's FlexBox Layout for generating the items but i don't really know how to create that scrollable view. I would literally pay to get this done.
I don't think you can make RecyclerView scroll in Both way. U can Create Nested RecyclerView if that is what you are looking for.

How to detect the type of scroll and then assign the touch to vertical or the inner horizontal scroll view

I have a RecyclerView which has a several View Holders and some of them are horizontally scrolling. To improve the usability of my application, I need to detect the scroll based on angle (say 30 degrees to X axis) and depending on that, assign that to child's Horizontal scroll or let it's parent's vertical scroll handle it.
From #suragch's answer https://stackoverflow.com/a/46862320/10165076, I understood we can intercept the touch event of the parentView, but I have a hard time coding that. If you can please help me here, it would be much appreciated.
Edit: Going further deep into usability, I need this to work smoothly even when the parent view is moving with the momentum of the fling.
Of the apps that I know, the Play Store app handles this perfectly, I tried to search for a solution online, but none of them could provide an approach that works as well as the Play Store does.

RecyclerView expanding background

I have a RecyclerView in which I add items regularly. I want the background of the RecyclerView to expand while the list of items grows.
For example, if the list has two items and a new one is added, a new part of the background is discovered, and so on...
What I expect
The complete RecyclerView is as in the image below. The user can only see a part of it, but discovers the rest when he/she scrolls up or down (which is why RecyclerView exists, I believe).
Here we can see that the whole background is actually expanding beyond the screen's top and bottom border. So whenever the user scrolls the RecyclerView, the background moves with it (matching the movements of the list).
I'm completely lost with that, do you have any idea how to achieve such a behavior?

Smooth scrolling for JLists like in web browsers

I wan't smooth scrolling for a JList that shows some search results. With the default unit increment of the vertical scroll bar the scrollling speed is too slow. When increasing the unit increment the scrolling speed is faster but for the user the scrolling looks very abruptly and not very smooth.
Is there any built-in functionality or any other approach that allows smooth scrolling like in web browsers? Every proposed solution I found so far (e.g. this one) just increases the unit increment but that's not what I really want (or what a user is likely expecting).
JList implements Scrollable to achieve this. You can override getScrollableUnitIncrement() to return your preferred increment for a given orientation and direction.

Eclipse android widget moving

I am designing my activity screen using eclipse but whenever I move an object e.g. a button it snaps around and I find it hard to position things where i want them.
Is there some setting I can change as as soon as I add a second button it snaps the other button to another position it is so annoying!
Also if I have an image button why can't i resize this, even with a normal button if i try to make it larger it just fits to the text and wont make the button bigger or it just flicks to a random place on the activity?
thanks
Probably you're trying to place components freely in the View but you're not considering the LayoutManager behavior. If you try to position your component in a LinearLayout, for example, the components will be placed following its rules, and these components will not stay where you drop them.
Try to understand better how the layouts works on Android. But for now, the AbsoluteLayout or RelativeLayout may be what you're looking for.
About the components size, you'll need to understand better how to use layout properties for these components. See the question How to size buttons for more information.

Categories