开发者

providing special effect to view of android screen [closed]

开发者 https://www.devze.com 2023-02-21 21:39 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andc开发者_运维问答annot be reasonably answered in its current form.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and c开发者_运维问答annot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 10 years ago.

I would like provide and animation effect but i don't how to do. Even i don't know what type of effect it should be called so that i can search on Google.

So my problem is ..

when user click a button a view or a layout should be display. i want to give effect to that view like ... it should be look like that that view is coming from left side of screen to right side and finally it should display my view.


modification like you want:

Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(1000);
animation.setStartOffset(0);
set.addAnimation(animation);

animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, -1.0f,
        Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
        0.0f, Animation.RELATIVE_TO_SELF, 0.0f);
animation.setDuration(1000);
set.addAnimation(animation);


You can also check the API demos in the Android sdk. There are a few animations demo (in Views > Animations).


AnimationSet set = new AnimationSet(true);

    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(1000);
    animation.setStartOffset(0);
    set.addAnimation(animation);

    animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
            Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
            -1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
    animation.setDuration(1000);
    set.addAnimation(animation);


public static android.view.animation.Animation in;
in = AnimationUtils.loadAnimation(ctx, R.anim.slide_in);
view.startAnimation(in);

you may define the animation in a seperat xml like:

<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator">
<translate 
    android:fromXDelta="100%p" 
    android:toXDelta="0" 
    android:duration="300" />
<alpha
    android:fromAlpha="0.0" 
    android:toAlpha="1.0" 
    android:startOffset="0"
    android:duration="300" />

edit: here a animation from left to right, play a bit around:

<set xmlns:android="http://schemas.android.com/apk/res/android"      android:interpolator="@android:anim/accelerate_interpolator">
<translate 
android:fromXDelta="-100%p" 
android:toXDelta="0" 
android:duration="150" />

0

精彩评论

暂无评论...
验证码 换一张
取 消