Skip to content

Latest commit

 

History

History
41 lines (29 loc) · 972 Bytes

EasyDimension.md

File metadata and controls

41 lines (29 loc) · 972 Bytes

EasyDimension

EasyDimension用于快速的在系统提供的各种尺寸间(PX, DIP, SP, IN, PT, MM)进行转换。

Sample Activity

特性

  • api简单直观

用法

  1. 传入待转换尺寸
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
  1. 输出转换后的不同尺寸的数值
dimension.toPX()
dimension.toDIP()
dimension.toSP()
dimension.toPT()
dimension.toIN()
dimension.toMM()

Example

将30dp转换为px

val pxResult = EasyDimension.withDIP(30).toPX()