set View Y Coordinate - Android User Interface

Android examples for User Interface:View Position

Description

set View Y Coordinate

Demo Code


//package com.java2s;
import android.os.Build;
import android.view.View;
import android.view.animation.TranslateAnimation;

public class Main {
    public static void setY(View view, float y) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
            TranslateAnimation anim = new TranslateAnimation(0, 0, y, y);
            anim.setFillAfter(true);//from  w  ww  . java 2s. c o m
            anim.setDuration(0);
            view.startAnimation(anim);
        } else {
            view.setY(y);
        }
    }
}

Related Tutorials