views:

409

answers:

1

I created an activity which holds 3 custom components (defined in xml). 2 components extend View, 1 extends SurfaceView. They all lie in a LinearLayout, deviding screen real estate equally amongst the components. Click to see. I'm new so I can't post images directly...

Now I would like to maximize one View when it is clicked (using a sliding animation). The other two should slide out to the bottom. All should run at the same time and the animation needs to hold when the desired view is maximized.

I created two animation (res/anim): shrink_view.xml and max_view.xml

  <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android"     android:interpolator="@android:anim/accelerate_interpolator">
        <translate android:fromYDelta="0" android:toYDelta="100%p" android:duration="4000" />
        <scale 
            android:fromXScale="1" android:toXScale="1" android:fromYScale="1"
            android:toYScale="0.0" android:pivotX="0%" android:pivotY="50%"
            android:fillAfter="false"
            android:startOffset="0" android:duration="4000" android:fillBefore="true" />
    </set>



<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator">
    <translate android:fromYDelta="0" android:toYDelta="100%p" android:duration="4000" />
        <scale 
            android:fromXScale="1" android:toXScale="1" android:fromYScale="1"
            android:toYScale="100" android:pivotX="100%" android:pivotY="100%"
            android:startOffset="0" android:duration="4000" android:fillBefore="true" />
</set>

But this doesn't do what I want. I'm thinking my attempt might be a deadend. So can anyone please provide some help?

A: 

I haven't tried what you're doing, but you might find this helps you. It's a tutorial on how to animate changing Views on a button press. It uses the ViewFlipper widget to change between ViewGroups (e.g. LinearLayouts or RelativeLayouts which contain TextViews, Buttons and so forth) using some built-in animations. It's a bit different from your situation since he changes the whole screen with his animations, but it might put you on the right track.

Steve H
Thanks, I will check it out. ViewFlipper sounds like a start.By the way: was it hard to understand what I am trying to do? Obviously, I am not a native speaker and I find it kind of hard to express these very specific problems...
steff
No, understanding your question was easy. Compared to many new peoples' questions, this one is great. Often they ask a question in two sentences, don't give any detail of what they've tried or what they're really trying to achieve, and then expect someone to be able to magically answer them... Your question was fine. The only thing you could do is edit your question to add more information as to what happens when you run that code, but I think you've said enough for someone who knows a lot about View animations to understand your problem.
Steve H
Thanks, that helps a lot. Getting into Android seemed so easy from the start. But it's getting more cumbersome right now...
steff
I'm glad I could help, and I agree, it's easy to get started but rather difficult after that! So many things which you think should be easy really are not. However, you can find tutorials for almost anything on Google, and people on this site are generally helpful if you have a specific question - so it's possible to teach yourself. Also, if you're happy with the answer, could you mark it as "accepted"? That tells people that the problem is solved and awards me 'reputation' points for helping someone. If you still need help, update the question based on the new things you've tried.
Steve H
This post might also be useful for you: http://stackoverflow.com/questions/2239442/android-pro-grammatically-adjusting-margins
Steve H
Okay, I will mark the question solved as soon as I find time to look into this. atm it's rather difficult for me but I hope I can do it tomorrow. And thanks for your help so far!I agree there are many tutorials around but I feel that some variations of android.media are not very well covered. I am desperately looking for a way to preview the camera (SurfaceView works well) and then decide wether to take a picture or record a video, for example. No luck so far. But maybe I am asking a new question.btw: do you get notified via email when someone responds to your posts? I don't. Regards, Steff
steff
I'd say there are more than just "some" features which aren't well documented. :P A lot of things have so little explanation that the only way to make sense of them is to find an example application. As for your question about previewing the camera, that should indeed be a separate question. You can turn on email notifications from your account page, under preferences, but you should also see a box when you log in telling you about replies since you last visited the page.
Steve H
That's good to hear that I'm not alone. Not well documented features drive me nuts. It makes things so hard and tedious.So I'll ask a new question. About the email-notification: there's only one once a day. I received my 1st today at 12:03 pm local time :( That's some serious lag...
steff
Ah, I could have sworn I only had the option for once a day as well but when I checked just before posting that comment, I suddenly only had the option for emails on all activity. It's probably something linked to reputation; in order to cut down on their email traffic they only give the more verbose option to people who have shown that they contribute to the site.
Steve H