EasyDimension用于快速的在系统提供的各种尺寸间(PX, DIP, SP, IN, PT, MM)进行转换。
- api简单直观
- 传入待转换尺寸
dimension = EasyDimension.withPX(value:Float)//原始尺寸单位PX
dimension = EasyDimension.withDIP(value:Float)//原始尺寸单位PX
dimension = EasyDimension.withSP(value:Float)//原始尺寸单位SP
dimension = EasyDimension.withPT(value:Float)//原始尺寸单位PT
dimension = EasyDimension.withIN(value:Float)//原始尺寸单位IN
dimension = EasyDimension.withMM(value:Float)//原始尺寸单位MM
- 输出转换后的不同尺寸的数值
dimension.toPX()
dimension.toDIP()
dimension.toSP()
dimension.toPT()
dimension.toIN()
dimension.toMM()
将30dp转换为px
val pxResult = EasyDimension.withDIP(30).toPX()