Android home screen swipe feature - android

How can i implement home screen swipe feature of android for a user to swipe between 2 view which covers the entire page. During the swipe the View must animate 100%, but the background must move by only 20%.

I have extensively used: custom scroll view for my app using vertical scroling.
It should be possible to put a bitmap or the like in the background and then when user swipes, manually move/animate the bitmap a factor of 0.20, unless at the edge of the bitmap of course.
Or, as you indicate, having two views. Then you just have to somehow have to, either make the background view ignore user input and let the top view control it, or find a way to pass the input down to the background, having it automatically use a factor 0.20.
Have not tried something similar but believe the link above gives you a lot of control over what is happening.

Related

How to make an image move off of the screen in Android?

I'm trying to make an image move completely off of the screen in an Android app. I already have the code that allows it to move across the screen, but it stops at the side, and it can't go outside of the screen. Is there any way to make it so it can go off of the screen?
You can use scrollview for this. Set maximum width/height you want. It means whether you want to move view horizontally/vertically. Then you can apply possible animations using setX()/setY() method. This way, you can move view off the screen & by changing X/Y position you can get it back on the screen.
I just tried it using setX/setY method.

make main view of app larger than the phone's screen

working on an app and The way I want to set it up is different than what I have ever done before. I want the main activity when launched into the app to exceed past the boundaries of the physical phone screen, and for the user to be able to swipe out to parts of the app that they can't originally see.
I am not sure what the terminology is or what methods or classes etc to use. Any info that could point me in the right direction would be great! Thanks!
Just some clarification:
I think what I'm trying to say is the second thing you talked about. Imagine if you place a iPhone for example in the middle of a piece of computer paper. What I want to achieve is to have the whole view the size of the paper, but only be able to see the size of the iPhone's screen at a time. So you can go up a little bit and see what was above the screen, or left or right
If you want more screens and be able to switch between them, use ViewPager.
If you want one large view bigger than screen, you can either combine ScrollView for vertical scrolling and HorizontalScrollView for horizontal scrolling, or make some custom View, which will be able to scroll (you have to implement it on your own) in both direction.
If you want to have just some views outside of the screen and bring them to visible area on some event, you can use RelativeLayout and set to its views proper margin.
If you want something else, add more information, how it should look and act like.

Android game programming big layouts

I wanna start a new project. A little "Jump n Run", but I have questions:
The levels will be bigger than the screen. How can I make a big Layout and edit it?
And how do the view "follows" the player, if he moves.
I dont want code samples. I only want basic ideas how to do it.
I suggest you have a look at the SurfaceView. It allows you to render bitmaps to the screen. In your case you could create a bitmap that is larger than the screen and have the user navigate it with the use of their finger (so you'll also have to also use your touchscreen). Basically what you will be changing when the user wants to go to a new location would be the src rect parameter in the drawBitmap method.
I hope this gets you started.
You could specify the layout to whatever pixel size you want (even if it's larger than any screen size would be), and then use scroll views to allow the user to scroll to other areas of the screen. Check out the Android developer docs on horizontal scroll view.

How to make a background image similar to scrolling wallpaper in Android?

I use a navigation-based iOS application. I want to make a background similar to desktop wallpaper in Android.
So when I go to another View the current View and it's content goes outside of the screen but the background image slightly moves only.
See a sample screenshot here.
Why not have the base subview set to the size of the background wallpaper (ie larger than the screens width) and start with it left aligned. Then have a paged UIScrollView on top of that. When the user scrolls the UIScrollview, hook into the UIScrollViewDelegate method
- scrollViewDidScroll: and pass it through the the base subview, telling it to animate in accordance.
This shouldn't be too hard but you'll probably want to tweak it a bit to get the feel you want.Try playing about with the various delegate methods in the UIScrollViewDelegate protocol to determine the best time to start the animation.

Android TranslateAnimation after scrollTo() = undrawn view

This might be a "duh" question but I'm going to go ahead and ask it anyway.
I have an oversized (bigger than the screen) RelativeLayout, and I'm using swipes to start a TranslateAnimation from viewing one part of the layout to another. Say for instance the layout is two screen wide and two screens tall. After the nice animation to shift the screen, I was using View.scrollTo() to set the new position. This works fine going from the first screen (top left at 0,0) to one of the others. When I swipe to animate back to the first screen though, because the View.scrollTo() invalidated that part of the layout (I assume), that part of the layout is all black as I animate through it. I tried a couple things to get it to redraw itself after the scrollTo() but haven't had any luck, so I figured I'd ask here.
thanks!
joe d
I can't help with your specific problem since I've never tried working with a layout bigger than the screen, but there might be another way to achieve what you're trying to do. If you simply want to be able to finger-swipe from one View to another, without ever displaying part of one screen and part of another (i.e. you aren't smoothly panning around a large View but rather just jumping from one distinct section of the layout to another), then these tutorials might help, here and here. They show you how to use touch events and the ViewFlipper widget to change between Views using animations.

Categories

Resources