I think that this is a simple question but I can't figure it out, I have a Scroll View with some text inside and it works perfectly, it only enables scrolling when the content doesn't fit into the screen. The thing is that I want to scroll the content no matter if it fits or not until the last line of the text reach the top of the view leaving blank space below and obviously "hiding" the content above it. I don't know if I'm explaining myself very well, thanks in advance!
Add a dummy view with height equal to the height of device's screen beneath your textview in scrollView.
Related
My UI consists of a ScrollView that takes the top 50% of the screen and under that two buttons that are attached to the bottom of the screen; YES and NO. The content of Scrollview is text that for most phones does not fill up the visual area of the ScrollView. However sometimes the text can be longer, such that it fills beyond the visual area of the ScrollView, hence the reason I added the ScrollView.
My problem is this; even when the ScrollView has very little text and does not need to scroll to show all of its content it still scrolls. The user can scroll the content up a slight amount. I'd like the View to instead not allow any scrolling if all the content is visible.
Is there an easy way to achieve this? Or do I have to implement that myself?
You cannot disable the scrolling of a ScrollView. You would need to extend to ScrollView and override the onTouchEvent method to return false when some condition is matched. To get help with extending, please read the answers to Disable ScrollView Programmatically?
I have multiple TextViews inside a horizontal LinearLayout and i need the middle text view to have ellipse=middle so that when the middle text is long enough, it pushes on both sides but the other views don't go out of bounds, but instead the middle TextView shows the '..."
Here's how it should look.
Setting the items normally, wrap_content for all in a horizontal LinearLayout will make the at ASAP text be pushed outside of the screen on Android (the above screens are from the iOS app).
Any ideas on how to accomplish this? Perhaps with a ConstraintLayout somehow ?!
Yes, i would recommend a ConstraintLayout. Top item to the top of the view, bottom item to thr bottom of the view then the middle item attached to these two views. You could also use barriers.
In my app I have a scroll view with n number of data to be listed out. There are two buttons one is named as UP placed above scroll view and the other is DOWN placed below scroll view.
Using the UP and DOWN buttons the list of views can be scrolled.
When the scroll bar is in top the Up button will be invisible and when the scroll bar reaches the bottom the DOWN button will become invisible, I have written logic for this using the getScrollX() method.
Now my problem is when there is very few data for example 3, the scroll bar will not be visible and the layout cannot be scrolled, in such a case both the UP and DOWN buttons need to be in invisible. How to do this, please suggest me a way?
You can try and use a ViewTreeObserver to check the dimension of the View inside your ScrollView. If the dimension exceeds a certain limit (such as the screen size), the ScrollView will be scrollable. See this preview SO answer for more details. Hope that helps!
I'm experimenting to see if the layout scheme I want to use is possible. I want to have an XML layout that's scrollable. Within that scrollable layout, I want to have a single line going horizontally across the screen (I used just a View with a fixed height and different color). When that horizontal line reaches the top of the screen, and as I scroll down through the layout, I want it to stop and remain at the top of the screen while being able to scroll through everything below it.
I've been messing around in XML trying to get it to work, basically putting a bunch of junk before it and after it.
Any ideas as to how that might work? Would I have to do something fancy with the java code to fix the red line at the top when the scroll position reaches a certain point? Your help would be greatly appreciated.
I am assuming you want something like Gmail app where when you scroll a mail the header sticks on top... To do this, you need 2 views. You have your regular scroller below and overlay a fixed view on top (you can use a relative layout to do this). When your cell goes past a certain spot, you want to populate and set the visibility of the fixed view to VISIBLE. This would give the impression that the view you want to 'stick' to the top really just got stuck rather than scrolled out of view. You'll have to work out the opposite scrolling scenario too based on the location and height of the scrolled cell/view.
HTH
Does anyone know what android:isScrollCOntainer = (boolean) or $(View).setScrollContainer(boolean) do?
At first I thought this would be the answer to set a View inside a ScrollView NOT to scroll with ScrollView, but it doesn't seem to be the case.
On Android Developers it says,
"Set this if the view will serve as a scrolling container, meaning that it can be resized to shrink its overall window so that there will be space for an input method. "
Can anyone kindly explain what this description means?
What is a scrolling container in this case?
What kind of input method is available?
A scrolling container is one where the size of the container is independent of it's content.
For instance you can make a ScrollView or ListView of height 100 pixels, but you can fit as much content in as you want. Similarly regardless of the size of the content in the view, you can set the size the of the View to whatever you'd like.
If a container is scrollable, then Android knows it can shrink the size of the container without rendering parts of the content of the container inaccessible (since the user can just scroll down to see things not on screen). It uses this for when the SoftKeyboard is opened - if a container is scrollable it will shrink it as much as possible in an attempt to keep all of the elements on screen.
So ScrollView, ListView, GridView etc are all examples of scrolling containers.
I am looking in to the same thing and I am not sure exactly what it means either. The input method is however the soft keyboard. Changing it affects how the views resize when an edittext is clicked and the keyboard pops up. Look in to android:windowSoftInputMode for more information.
I hope this was at least a little bit helpful!