Android examples for User Interface:View Property
Safely gets elevation of a view by checking to make sure View.getElevation() is supported
import android.os.Build; import android.view.View; public class Main{ /**//from w w w. j a v a 2 s. com * Safely gets elevation of a view by checking to * make sure View.getElevation() is supported * * @param view to get elevation for * @return view.getElevation() if supported, otherwise returns -1 */ public static float getElevation(View view) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.L) { return view.getElevation(); } else { return -1; } } }