implementing curtain transition of imageviews in android - android

I want to implement the curtain animation like in ios in my application.For this i have taken a framelayout and added two linear layout and in the top most linear layout i have put two imageviews and i am applying translate up and down to the imageviews.
It is working ,but the problem is that it is not smooth as compared to the ios.Does anybody have any better solution for smooth transition of the image views?

The smoothness of the transition will be dependent mostly on the device and it's computing power. Have you tried your app on an actual device, or just the emulator. It might just be running slow on the emulator.
Also, perhaps its the loading of the images that are causing things to be slow. Have you tried caching them in memory?

Related

Are too many views in XML bad?

I have an XML file with about 150 views. Yes, I know it is a lot and I did get a message from Android Studio saying I can't exceed 80 views. But I can't drop views any lower than 150. I considered using list view but it works the way I wanted it to.
The question is, will this many views make the app crash/slow the device? I've tried it on my s7 and it works perfectly fine. My lowest API is 17 which is 4.2. Wouldn't 4.2 devices be able to handle this XML without any problem?
Thanks.
The problem with having an excessively large number of Views is that Android often needs to measure, layout, and draw them, and it will traverse the entire View hierarchy to do this. If the number of Views is so large that this traversal takes more time than the screen refresh rate, you will skip frames and your UI might appear to lag or be choppy.
If not all of those Views need to be on screen at once (for example, if you are using a ScrollView to hold a very large container that the user can scroll through), then you should probably switch to using RecyclerView.
If all of those views need to be on screen at once, then you might consider writing custom Views that can display your content all at once instead of having individual Views that draw individual things. This can drastically reduce the time and complexity of the measure/layout/draw traversals.
It's difficult to suggest an approach without knowing more specifics about your UI, but hopefully that explains the issue.

Android - Animate View to Wrap Screen

I'm trying to make a View (in this case an ImageView) slide off one side of the screen and simultaneously reappear on the other. However, most of the search results I have found include Samsungs news about launching devices with wraparound screens for 2014, or this same task on other devices (such as Make Image Wrap Around Screen Edge? - iPhone Obj-C). Is this currently not possible in Android?
I've tried doing this with two animations on the same view, but I haven't had much success. Chaining the animations resulted in only the latter animation being performed, and performing them simultaneously caused them to negate each other. I have also looked into the various Interpolators, but I haven't achieved this effect. Any suggestions?

Faster scrolling background

I am developing a (vertical) scrolling shooter app for android. Everything is working fine, its fast and smooth... but so far it just has a black background. I wanted to make a scrolling background by creating a very tall bitmap of the background, and show a part of it using code like this:
canvas.drawBitmap(background_bitmap, sample_rect, fullscreen_rect, null);
where the sample_rect gets moved along as the game progresses. The code works, but the frame rate has now plummeted and is no longer smooth.
I can think of some possible ways to do this better, but it seems silly to reinvent the wheel if there is a standard method that everyone uses. Any suggestions?
EDIT: By the way the image is not a simple pattern that I can implement with small tiles.
EDIT: Should I be employing BitmapShader? Should I resize my bitmap to match the screen before the game starts?

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.

ImageViews sometimes not displaying in FrameLayout activity

The top level layout in my activity is a framelayout. I have completed, debugged and tested this app and it works exactly like it should in all respects on my g1 and on various emulators. But on 3.7-inch displays running 2.1+, some imageviews packed in a linearlayout
are periodically not visible. I know that they are there because you can touch and drag them with effect in the app. So I assume somehow
they have gotten under the SurfaceView that is the main component of the app. This is apparently so even though the SurfaceView is declared in the xml prior to the LinearLayout. However, the ImageViews IN the LinearLayout are added programmatically towards the end of onCreate().
Framelayout stacks everything that is added to it, one on top of the other--the only way you will see more than one child of a frame layout is if they are smaller than the screen and are placed apart from eachother.
Oddly, sometimes the imageviews ARE visible--it is random. Anyway, I've been trying to combat this with framelayout.bringChildToFront(View v) on the linearlayout without success.
I wonder if anyone has any insight into how the behavior could be random like that, and how I should code these imageviews
to keep this from happening, and why the problem appears only to occur on 3.7 vs 3.2 inch screens (as it happens, the two 3.2-inch screens were both htc, so vendor might be factor too).
[edit] Actually, I've determined that this is a 2.2 issue, not a screen size (or even vendor) issue. Can't ensure that ImageViews added to a framelayout with a SurfaceView
in it will appear on top of the surfaceview. I ran some tests in the respective onDraw() methods and the imageviews are 'visible' (0), and nothing does anything to the alpha of the drawables, which are there as well at ondraw(). [/edit]
Any insight would be welcomed.
Ken T.
I had to draw the drawables in SurfaceView's doDraw() method, and I had to change the file names of the drawables. I think this was a case of malicious code somewhere. I had to scrap the ImageViews and transfer my touch-handling code elsewhere.

Categories

Resources