center View on X axes - Android User Interface

Android examples for User Interface:View Center

Description

center View on X axes

Demo Code


//package com.java2s;
import android.support.v4.view.ViewCompat;
import android.view.View;

public class Main {
    public static float centerX(View view) {
        return ViewCompat.getX(view) + view.getWidth() / 2f;
    }/*  w  w w .  j  a v  a2s. co  m*/
}

Related Tutorials