get View on Screen X coordinate - Android User Interface

Android examples for User Interface:View Position

Description

get View on Screen X coordinate

Demo Code


//package com.java2s;
import android.view.View;

public class Main {
    public static float getScreenX(View v) {
        int[] loc = new int[2];
        v.getLocationOnScreen(loc);/*ww w.j a va 2s  .co m*/
        return loc[0];
    }
}

Related Tutorials