Android studio scrollview always goes to top after editing object - android

So, in my app, I have a ScrollView and I have objects down in that ScrollView so to edit them I have to scroll down.
The problem is that after each time I edit an object (A Button, a TextView or anything else) the ScrollView scrolls back up to the start.
It is a pain to scroll down every time I have to do a small change, so I would really like help.
I can publish the XML if needed

you can try this
yourScrollView.scrollTo(0,your_button.bottom)

Related

Start animation if view is in focus

I have a android app and with several Textviews inside linear layyout which is inside scrollview. On a button click I can bring focus and animate any textView (like move left to right). But What I want is, On Scrolling, if a TextView has Focus, animation for this textView should start. Just like this website.
I have an idea, which is: If scroll changes, check textview.hasFocus(), if true then startAnimation. But I don't know which method to use for checking 'if page scrolled'? I don't even know if this is right approach? Please help.

Fix the position of a View that is in the list while scrolling the same list, programmatically

Let's assume that I have an ImageView and a TextView one over the other. These two views are the first two elements of my RecyclerView. The other elements of the RecyclerView are of the same type.
ImageView(element 0 of RecyclerView)
TextView(element 1 of RecyclerView)
element2
element3
...
So, normally in this scenario, if you scroll down, ImageView and TextView will go upwards and disappear from sight as i continue scrolling. What I want is, ImageView to disappear by going up out of the screen, but TextView to stay at top of the screen, even if I scroll further, the other elements of the RecyclerView will go up and TextView will stay at a fixed position top of the screen.
---TextView(FIXED)---
element6
element7
...(scrolling)
I thought about this and couldn't find a good programmatical solution, but I realised I could do it with a little bit of cheating.
RecyclerView will work just like in the scenario I mentioned. But when TextView starts to leave the screen from the top, a clone TextView will be visible and brought in front of the RecyclerView, so even if my real TextView disappears from the screen, clone TextView will hold its place.
However, this solution did not satisfy me. Also I didn't try out my idea and don't know if it will work completely. I searched a nice solution for this, but I couldn't find any closely-related question.
I wonder if there's any way to achieve this behaviour without using new views or etc.
Have you looked into Sticky List Header libraries like this? I bet if you dove into their source code, you'd find some good inspiration.

Android responsive scrollview

My question is very simple ,I am familiar with ScrollView but i am suffering this problem from a long time.
I have put ten EditText in ScrollView but when i click on EditText my keyboard appear and then the problem start . my keyboard cover half of the screen and i am not able to scroll to the last item. I don't want my view to re size.
I want a ScrollView like iOS . I want my ScrollView to scroll to bottom and smoothly without re sizing the View.
Please help me with idea and code, so i can make my application cooler and nicer.
Add this in your activity tag in the manifest
android:windowSoftInputMode="stateHidden|adjustPan"
You should also be aware of this article

How to keep views in scrollview (that are inside a linear layout) that are not visible from being created?

I have linear layout inside a scrollview, and i would like to keep those views which are not visible(which are inside the linear layout) from being created until they are either visible or near to being visible. Like adjacent to one that is visible. I don't know if for example if turning off visibility will keep the View from being created(in terms of resources), or if gone could be used.
Update: The reason I am asking this question is because scrolling is taking a heck of a long time when there are say 30 view elements in the linear layout. These are not large view elements either, about what you would find for a record in a listview. I should add that the whole scrollview is inside a fragment.
Thanks
You have a LinearLayout(vertical) with 30 children. If you scroll to the bottom, which views would then be "created"?
If only the visible(or near visible) ones, then you can't measure how far down in the scroll they will be any more.
If at that point you're just saying you should create them when they first appear, and stay around afterward, that could work. However, once you scroll around some, you'll still have a bunch of views, and the same problem you have now.
Scrollviews exist and I happen to be using one.
True, but that doesn't necessarily means it's the best tool for the job. I tried something similar with my first Android project. I didn't know much about ListViews, and ended up rolling my own adapter that sounds eerily similar to what you're doing.
Long story short, the performance was bad. It did work, but once I(finally) switched to a ListView, the difference was nothing short of amazing. I'm just trying to keep others from going down that road. It was days of wasted time trying to get it "just right".

Buttons on scrollview issue

This is my first question on StackOverflow, but I've learned a lot here already.
Now I have a problem, which I couldn't solve.
I have a horizontal scroll view with some buttons on it (let's say 20 buttons). When I scroll and stop the scrollview, it needs some time to accept clicks by buttons. I mean - onClick method desn't fire.
It could be observed best when scrolling is fast, and stops rapidly because of coming to the end of scrollbar.
Then it takes 2 clicks to get the button action.
I think this is some focus problem, or it's about of scrollview events implementation on scrolling.
As a ScrollView moves along, it unloads out-of-focus things and loads coming-into-focus things. This may be why the button's click takes a bit to register.
A project of mine learned this the hard way after we had already implemented everything in it. It worked great before the ScrollView had large amounts of content. Then once it did, it was super laggy and that's when we learned this.

Categories

Resources