Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import android.content.Context;
- import android.util.AttributeSet;
- import android.view.View;
- import android.view.animation.AnimationUtils;
- import android.widget.LinearLayout;
- public class NowLayout extends LinearLayout {
- public NowLayout(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
- public NowLayout(Context context) {
- super(context);
- }
- public void switchFrame(bool flyIn) {
- final int heightPx = getContext().getResources().getDisplayMetrics().heightPixels;
- boolean inversed = false;
- final int childCount = getChildCount();
- for (int i = 0; i < childCount; i++) {
- View child = getChildAt(i);
- int[] location = new int[2];
- child.getLocationOnScreen(location);
- if (location[1] > heightPx) {
- break;
- }
- if (flyIn) {
- if (!inversed) {
- child.startAnimation(AnimationUtils.loadAnimation(getContext(),
- R.anim.slide_up_left));
- } else {
- child.startAnimation(AnimationUtils.loadAnimation(getContext(),
- R.anim.slide_up_right));
- }
- } else {
- if (!inversed) {
- child.startAnimation(AnimationUtils.loadAnimation(getContext(),
- R.anim.slide_out_left));
- } else {
- child.startAnimation(AnimationUtils.loadAnimation(getContext(),
- R.anim.slide_out_right));
- }
- }
- inversed = !inversed;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement