Class DimensUtil

  • All Implemented Interfaces:

    
    public class DimensUtil
    
                        

    A helper class with methods to deal with dimensions and orientation.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      DimensUtil()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      static int getPixFromDp(Context context, int dp) Get the pixels for dp rounded to int.
      static int dpToPx(Context context, float dp)
      static int getDpFromPix(Context context, int pix) Get the dp for given pixels rounded to int.
      static int getScreenOrientation(Context context) Get the current screen orientation.
      static boolean isOrientationPortrait(Context context) Returns true if screen orientation is Portrait
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DimensUtil

        DimensUtil()
    • Method Detail

      • getPixFromDp

         static int getPixFromDp(Context context, int dp)

        Get the pixels for dp rounded to int.

        Parameters:
        context - the context
        dp - the dp to convert to pixels
        Returns:

        the pixels for the given dp

      • getDpFromPix

         static int getDpFromPix(Context context, int pix)

        Get the dp for given pixels rounded to int.

        Parameters:
        context - the context
        pix - the dp to convert to pixels
        Returns:

        the dp for the given pixels

      • getScreenOrientation

         static int getScreenOrientation(Context context)

        Get the current screen orientation.

        Parameters:
        context - the context
        Returns:

        the current orientation

      • isOrientationPortrait

         static boolean isOrientationPortrait(Context context)

        Returns true if screen orientation is Portrait

        Parameters:
        context - the context
        Returns:

        true if screen orientation is Portrait