Drag a view programmatically - android

I'm writing playing cards game. I have implemented dragging and dropping one view onto another based on this tutorial.
Now I want to animate opponent moves.
Is there easy way to to this?
I thought about using TouchUtils.dragViewBy(...), but it isn't supported on device.

for opponents move, shouldn't you use animations instead?
for this, you could use either the old API or the new one, or use a compatibility library instead .
do note that if you run animations on old android versions (even with the compatibility library) meaning API 10 and below, the view only looks to be on the position that you see it, but actually it stayed on the original position.

Related

Android Layout for Google Maps - Choose starting point Screen

Please have a look at this screenshot from Google Maps for Android. What layout is Google using for this particular screen?
Using multiple ListView controls here would be an overkill in terms of performance (or so I think). Also, because one can scroll on this screen, I don't think Google is using ListView controls here as ListView controls don't work along with ScrollView controls. Is Google using multiple instances of the all new CardView control on top of a ScrollView control here?
Can someone help with the best possible layout (from a performance perspective) for rendering this particular screen? I need to make sure my app supports lower end Android handsets so rendering performance is the number one priority but nothing like achieving it with clean, simple & reusable code + layouts (if possible in this scenario).
Thanks in advance!

Simple and compact chat user-interface

I am developing a multiplayer android game and I am trying to add a chat UI for players to talk to eachother.
I don't want this chat UI always visible because of space issues, I'd like there to be a tab that you can press or slide that will bring the chat menu up. I have a sketch so you can see what I mean...
How can I go about implementing this in android.
I know I am going to need to use EditText and TextView etc but How can I get the sliding thing to work.
EDIT: I'm not looking for a flat out answer. I just need guidance. What widgets, methods etc should I be studying
There used to be a SlidingDrawer in the Android SDK. It is officially deprecated and, to be honest, was never that good.
There is nothing in the Android SDK that directly replaces the old SlidingDrawer. The leading third-party implementation seems to be AndroidSlidingUpPanel, though there are probably others floating around.

Using Android Drag and Drop framework in My custom Launcher app

I am trying to develop custom launcher app (with unlimited number of home pages)and i need to implement Drag and Drop as done in Launcher2(android 4.2).
So i found two approaches
1) Drag and Drop framework
2) Use the android launcher2 way like implementation DragController, DragSource as explained here.
But i am struggling to understand why didn't Android guys didn't use the Drag and Drop framework developed by them in their own application. Can anyone brief regarding possible rationale behind their approach?( i mean in terms of memory/performance)
Thanks in advance.
The Android drag and drop framework is very basic as compared to the one used in the Launcher app.
The Launcher app has a myriad of "layers" and the drag and drop occurs accross these layers, namely the DragLayer, Workspace and the All Apps view etc. It uses window flags and dynamically adds/removes views to the DragLayer when a drag is in progress and a multitude of activities monitor the drag. For more details look at the DragLayer.java and Workspace.java files particularly.
Drag and Drop in Android Launcher is done as Overlay drawing within the same ViewGroup and in same window . But android drag and drop approach creates a separate window with a separate window type altogether .
Resource and memory wise standard android drag and drop approach is costlier.
If performance is very critical my suggestion is go as per Android launcher way else prefer standard android approach its easy and simple.
Drag and Drop framework is sice api 11.
My guess is, lot of code for launcher was written before that, and noone had time to refactor it yet. But api works similar like second approach.
http://javapapers.com/android/android-drag-and-drop/. This is the best drag and drop example since i have implemented the same in my application. Note: It will support versions only above 11. The drag and drop feature will not support for version 10. Instead u have to move the fields in a absolute layout by settin X and Y positons. But Absolute layout is completely deprecated...
You should use WindowManaager to control Drag And Drop if in case your Application is not so much complex. This is easy to implement and work on Position changed. get the code Here

StackView implementation in Android 2.X

Need to implement a View which contains 5 Images placed in stack order. When user move finger up or down at this View picture replace each other.
This approach looks like StackView in Android 3.0, but standard StackView displays applications and it works from API 11 level and I develop for Eclair.
Would like to know if you know some sources where this kind of view has already implemented for Android 2.X, or may be you'll give me an advice to try another one approach to implement this stylization kind.
One option may be to pull the StackView source from a recent Android source base and place it in your application. If I were to do this I would certainly change the package name, and in order to maintain forward compatibility I would see if the original class exists on the platform and use that instead.
If I were to implement what you describe without consideration for having StackView, I would think this could be done easily enough by overriding ImageView and giving my class an array of images to have the source cycle through.

Simulating the left/right sliding animation transition

I want to port my application on all Android devices, and I want to have the right/left animation on the activities transition on all Android platform versions. I know that this feature is implemented in the 2.0 version. How can I implement this feature for the lower versions?
You can simulate it on lower versions by using ViewFlipper for example, but I would not suggest it if you have a lot of View elements on your UI because this requires all the Activities' code to be merged into a single Activity. With a lot of Views you'll max-out the CPU/GPU limits pretty easily. All you get is messy code and bloated XML files.
This is the effect - http://www.youtube.com/watch?v=SZTiJmclaRc
My suggestion - just stick to what the platform API version offers by default and don't rape the hardware.

Categories

Resources