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
Related
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.
I'm building a layout within Eclipse for Android using the RelativeLayout. I lay down a simple stack of buttons one on top of each other. For some reason the button snaps to the first button position even though I clearly place it down on the last stack of buttons. I try everything to move it to the right position eventually I just let the layout builder stick it to the bottom of the screen edge.
When I try this view inside the app, the last button is magically snapped to some random spot usually near the top. Obviously incorrect. As a hunch I tried it again but I left it alone this time, when I laid the last button down again ( which within Eclipse Layout builder its snapped to the first elements position for some crazy reason). Surprisingly within the app itself it appears in the proper location. So this must be a bug with the Layout builder itself.
It looks horrible in Layout builder (almost unusable) and the position of UI elements totally wrong, is this some known bug with Layout Builder + Android or do I need some update or new SDK or something?
There are many reported complaints about the ADK Editor for Eclipse, but one alternative is to try DroidDraw
http://www.droiddraw.org/
The preference of some Android developers is to directly modify the XML. This often provides more flexibility as you can see the exact rules that are defined for your UI.
If you are looking at just stacking Buttons on top of each other, you may want to consider a LinearLayout.
http://developer.android.com/reference/android/widget/LinearLayout.html
This is a layout that arranges its children in a single column or a single row.
Relative layout every "view" is positioned relative to something else. It would help you to understand better if you look at the xml. You will see what each item is aligned on. It is difficult to get this layout right as you see especially when you design in eclipse and run on an avd or real device. Consider placing a linear layout inside the relative layout and your buttons in that. This way your button group is together in a row or column and next to this you could have text or something.hard to explain but group like things together and nest layout inside other layouts.frame layout only one item is viewable at a time,like pages in a book or slide images. I hope I explained this good. I have no idea why you would do buttons that way.absolute layout is x,y positions where you put it is where it stays. Like that's gonna work. Try a different screen density and things are bunched up in the corner.like I said the key is nesting the layouts
Hi there I am in the middle of developing my app and am just curious to find out whether or not this is possible.
Ok so I have loads of text in my Layout and I want to pragmatically control where the linear layout in the scroll view has been pressed.
For example I want to program my app to go in the middle of my text how would I do that?
What about using the "scrollTo" function. Programatically you will be able to specify the x and y to scroll to.
http://developer.android.com/reference/android/widget/ScrollView.html#scrollTo(int, int)
Here is an example of how to use the scrollBy and scrollTo methods. Essentially you give it an offset in pixels for the amount you want to scroll. You can use getScrollX and getScrollY to get positions, though it sounds in your case you might want to use "scrollBy" to scroll an offset based on the top of the scroll view and where the user pressed.
http://android-er.blogspot.com/2011/09/scroll-view-scrollby-and-scrollto.html
I have a ScrollView layout like this, for example:
<ScrollView>
<Component1>
<Component2>
<Component3>
<Component4>
...
</ScrollView>
Inside ScrollView I have some components, each of them can be anything like LinearLayout, RelativeLayout, TableRow, ...
Now what I want is I will scroll the view, when the <Component2> reach the top of the screen, it will be keep on the screen and <Component3>, <Component4>... will keep scrolling till the end of page. When I scroll down, <Component2> will only be scrolled when all the <Component3> has became visible. I saw this on an Iphone app and wondered how to achieve this on Android.
I don't know if I describe clearly enough but it is same like this video
http://www.youtube.com/watch?v=jXCrM1rzLZY&feature=player_detailpage#t=71s
When the tabs scrolled up to top, it stay there. And when scrolled down like in 1:36 of that video, it stay there until all the content below has became visible on the screen.
Does anybody know how to do this on Android?
I guess you could create a hidden copy of Component2 in a RelativeLayout that is setVisible(true) when the coordinates of Component2 are lower(Android draws from the top) than the top of the ScrollView. When the coordinates of Component2 are higher than the top of the ScrollView (.getTop()), Component2Copy.setVisible(false).
You may also want to disable them when changing their visibility. Good luck with this.
I have searched a lot but I couldn't find an answer.
I want to implement something like in Go Launcher. When you drag an icon in app drawer and move it out of container top or bottom bound, the list begins to scroll.
So far, I have tried following things:
Dispatch touch events to simulate scrolling - impossible while touching the screen
Use smoothScrollBy() method - almost there, but it scrolls only screen height distance
Use scrollBy() - it moves only the container and leaves blank space. I would put there some rows if only I could be able to reuse views that went off the screen.
I need the ListView to scroll SMOOTHLY.
So here goes ma question. Anybody knows how can it be done? I'll put a gratitude in About section of my app to person who will help me:)
using listview and try scrollToPosition(),or smoothscrollBy()