I am new to android XML layout and trying to make a layout that is similar to windows phone home screen. Following image tells what i am looking for.
What I have tried,
1) Horizontal Scroll View: this works for left-right swipe until the grid or list does not have a vertical scroll bar
2) Linear Layout with orientation Horizontal: Same issue as above
You can use a gesture detector to detect a swipe left or right.
http://developer.android.com/training/gestures/detector.html
You can then add an animation to animate the movement from one view to the other. How this works varies depending on how your layout is structured ( i.e. two views in one layout with one hidden, fragments that get swapped out ). There are a lot of examples on stack overflow.
swap fragment in an activity via animation
There is a Gallery View, but this is deprecated in API 16. They suggest ViewPager or HorizontalScrollView neither of which really provides the same functionality.
http://developer.android.com/reference/android/widget/Gallery.html
Here are some other options that I personally have not used.
Options for replacing the deprecated Gallery
I got this working using the ViewPager controller available in android
working code can be found here
https://github.com/harshitgoel96/ZoZo-Launcher-2
its still a work in progress, but my main two page start is working as expected.
Related
I'd like to be able to scroll through my main, outer layout vertically even if my thumb (touch) is within a horizontal scrollbox (which allows me only to scroll through its items horizontally). I've already tried replacing the horizontal scrollbox with a standard TScrollBox but without luck.
Examples of this can be found in applications such as Instagram (with their stories) and Facebook. A concept image is shown below from another question whose answer isn't applicable in Delphi.
Edit: there's a component in Android called 'Nested Recycler View' that does this exact thing I'm looking for. Is there anything similar for Delphi Firemonkey?
have you tried awsome controls from https://github.com/Zeus64/alcinoe
try to build single row of main layout with tabs and slide efect
I am trying to create an activity layout with two parts, where their respective size is dynamic. The activity should have two states:
Starting state:
The user scrolls the bottom part up to the second state (and back):
It's important that the change will be animated. I tried a few solutions so far but didn't manage to find the exact way to do that:
AndroidSlidingUpPanel - The panel acts as another layout, covering the upper view and moving the toolbar out of the screen.
Android Split Pane Layout - Correct behavior, but the splitter is dragged and not the bottom part (I don't want to have a visible splitter).
CoordinatorLayout with CollapsingToolbarLayout - I didn't find a way to limit the upper part from totally disappearing. Anyway I think that it's a bit abusing because I don't want to collapse a toolbar but just change the children's height with animation.
Is there a good way to implement this using another library, one of these that I perhaps didn't use correctly or with simple layouts? Thanks!
I found a custom version of the SlidingPaneLayout created by VLC, which is basically a vertical SlidingPaneLayout - the exact functionality that I was looking for.
I understand the items that are visible to the user will be loaded when using GridView. Does this also applied when using GridLayout?
I currently working on laying out the applications' icon like the applications screen does. When user pressed the icon of the application they are allowed to arrange the icon in an unoccupied space.
At the moment, I don't know which widgets is preferred to use. If GridLayout behave the same as GridView, I would stick with that so no need to change the code.
If you want to be able to drag icons to rearrange them I would consider using GridLayout with RecyclerView. Take a look at Drag and Swipe with RecyclerView
Part Two: Handles, Grids, and Custom Animations.
If you are unfamiliar with RecyclerView and ItemTouchHelper then also look at Part One first
I am using a ViewFlipper to toggle between views. I would like to get the same effect as Facebook's or Youtube's settings views, which is to keep a bit of the last view showing to the right. See image below. How can I do this?
Instead of using a ViewFlipper, try a ViewPager. The ViewPager is best, I think, if you want to have different pages and let the user control which one they see. It uses the paging animation by default, and you can specify page width so the user can see parts of the page next to it.
I want to give my app a nice touch by allowing users to slide the page left or right instead of just using next/previous buttons (similar to the home screen).
What is the best way to do that? I assume I would have to override one of the Activity.on... methods and that I would also have to put my page's main View in a ViewGroup that allows me to shift pages left and right.
ViewFlipper is your friend!
Here you can see a nice video of the ViewFlipper in action and also a very good tutorial:
http://www.inter-fuser.com/2009/07/android-transistions-slide-in-and-slide.html
The solution is even easier these days with the release of Compatibility Package r3. You can download here: http://developer.android.com/sdk/compatibility-library.html
It includes
ViewPager: A ViewGroup that manages the layout for the child views, which the user can swipe between.
PagerAdapter: An adapter that populates the ViewPager with the views that represent each page.
and Fragment versions of those, if you are that way inclined.
The pager code is compatible back to API version 4 (1.6), and I just implemented a dynamically generated viewPager coming off a dynamically generated ListView in about 2 hours. I'm a novice, so this is definitely the preferred path.
There is an example app here: http://geekyouup.blogspot.com/2011/07/viewpager-example-from-paug.html
If one wants to flip between two activities perhaps one can apply this animated transition:
Intent intent = new Intent(FirstActivity.this, SecondActivity.class);
startActivity(intent);
finish();
//transition using XML view animations
overridePendingTransition(R.anim.slideinfromright, R.anim.slideouttoleft);
Use GestureDetector to detect if the touch event is a scroll.
If the first event to the first call to onScroll is ACTION_DOWN then you should see if it was a dominantly horizontal scroll. If so then your scroll is started and you should shift the absolute position of the view that fills the page.
For non deprecated absolute positioning, see my answer here Android: Alternative to AbsoluteLayout (I really do need absolute positioning)
You will want to be cautions of whether you return true to consume the touch events or not.
GestureDetector does not have a callback for scrolling having stopped. You will have to check if there was an ACTION_UP before you call GestureDetector.onTouchEvent and if there was an action up and you did have an unfinished scroll then you should set the absolute position to the destination location and use a TranslateAnimation to make it look nice moving from current to destination.
Edit:
GestureDetector did not work well at all if the child views also wanted to respond to touch events. I ended up creating a subclass of FrameLayout (one of the most basic layouts and the closest thing to a non intrusive parent view) and overriding dispatchTouchEvent. I just took all the events and did the detection myself.
cant we use Gallery view here?? with the adapter the whole page can be inflated inside gallery view adapter getView() and it will manage the left right scrolling perfectly.