How to slide a image from one position to another in android? - android

I have requirement that , In my application I have an image that occupy the full screen,after 5 second it will slowly slide up upto 50% of the screen and stay there. Remaining 50% screen occupy another image same like it slide up from bottom to below of first image.
How I can do it?

You can start here.
There is a lot to learn on Android Animation and Graphics.

you need to use the animations API of android.
however, since the handling of animations has changed between pre-honeycomb and honeycomb, you need to decide which android versions are supported on your app.
if you have the minSdk to 11 or above, you can use the new API .
otherwise you can use the old API . you can also use the NineOldAndroids library that mimics the way the new API works, using the old API.
for both, you can look at the API demos of google (or the library i've mentioned).
so, for making the animation you've mentioned, you can use the ScaleAnimation (old API) and use the screen width as the parameters for before and after .

Related

Android Surfaces Look alike Layout in pre-Lollipop

I am trying to design a layout in Android but I don't even know how to call it. It is somewhat similar to Android Surfaces I would say, but actually the old Google Maps Entry details are designed more like it and i would prefer to target sdks prior lollipop.
I want that a picture is shown on top of the screen.
Below is a Headline and below that is a List.
When i scroll down, the image shall be put into the background and the complete block of other elements should float above, taking roughly the half of the image heigth additionaly.
When i scroll down further the Headline element should be fixed on top of the screen, the image completele covered and the list should float under the Headline.
How does Google Maps achieve this? I am not even sure if it is a List that is displayed there below the image. Any ideas? The name of that design would suffice, any guides or tutorials are very appriciated.
I'm sure this needs a visual explanation:
I want a design like the second screen shows it with a transition to the third screen.
Screenshots taken from Google Maps Android App.
And here is the new Surface Layout from Android 5.0 but as i said, i would prefer to do it compatible to lower versions and besides this does not look like the fluent transparant change i aspire.
Thanks for every help!
Found it. Can't believe it was so hard to find. The magic keyword is Sliding Panel
To those who stumble upon this question, here is the most referenced library, but searching for Sliding Panel will help as well.
Sorry for bothering...
https://github.com/umano/AndroidSlidingUpPanel

TextButton padding changing with Android version

I have been developing an app over the past few months getting ready for publication. Everything was looking just perfect. I was doing a few things with text in buttons - using my own 9-patch button backgrounds, changing the default font, repositioning textbuttons with setX() and setY() etc. I had some big buttons and smaller ones. Some were a tight fit amongst other objects on the screen, but it all worked, the buttons looked perfect on a variety of tablets and phones.
Then I remembered one last thing on my todo list which wast to change the android:minSdkVersion in my manifest from 8 up to 11. I needed to do this because the setX and setY methods are only available on android 3.0 and higher. But as soon as I did this, the text within my buttons was all screwed up. For a start it was white instead of black - easily fixed. But also the padding round the text was completely different. Buttons were now overlapping each other and looking unbalanced in a variety of ways.
So my question now is this: Is there any way to say "this software must only run on Android 3.0 (api 11) and above" AND "let all the text button characteristics be set to whatever that were with api level 8".
I have no idea why such things would happen - but it's better to just support the older platforms if you can help it. For example, if the only thing keeping you from using API 8+ is the setX() and setY() methods, you can use ViewHelper in the NineOldAndroids project to do this and support the lower API. For example:
ViewHelper.setX(myView, myXValue);
ViewHelper.setY(myView, myYValue);

AbsoluteLayout - do I have an alternative?

In an app I'm developing, I need to layout 2 to 5 buttons as if on the edge of a circle. The app starts with 5 buttons, but buttons gradually disappear (based on user input) until there are 2 of them.
I thought I would use an AbsoluteLayout control, and set the position of each button in code (taking into account the screen size). However, it says more or less everywhere that AbsoluteLayout should not be used. Since I'm targeting this app to Android 2.2 and up, I can't use the fancier layouts introduced with ICS.
I know I can use a RelativeLayout and play with the margins, but this seems less intuitive, and just as error prone, as using AbsoluteLayout.
Do I have any reasonable alternative?
I think, you dont have many alternatives. Except relative layout you mentioned, you could of course use FrameLayout and set left and bottom margin to position your buttons correctly.

Adding UI elements(textview, webview...) to a layout in code and be able to size and place them manually (dp or px)

I'm working on a UI class for an app. The goal I'm trying to accomplish is to be able to at runtime create UI elements and add them to the layout. I then want to be able to size and move them manually (in code). For example I want to add a webview whose size is 234px by 450px and is placed at 32, 32.
Currently I'm using a relative layout and placing objects in it and then moving them around. I can move things fine by using view.setX() and view view.setY() but using the view.scaleX() and scaleY() doesn't work in the way that I want.
Should I be using a relative layout or is there another option.
I'm building for API 15
I switched to an absolute layout, though it is deprecated it allows me the exact freedom and control that I wanted.

Android: Smooth fade animation

I'm attempting to fade between two background images on my Droid, but the animation seems to get 5fps if not less. Is there any method I can use other than fading in\out a couple image views that would be smoother?
You can set your background to be defined by a TransitionDrawable. Used it to develop a nice splash screen that fades in and didn't have any issues.
I'm not exactly sure what you want to do, but if you want to change from one screen to the other within the same app you should use the ViewFlipper.
View Flipper on Android Developer site
This will allow to smoothly change from one screen to the other (much like the iPhone way).
If it is about the actual Android background i can't help you. Sorry.

Categories

Resources