val a = context.obtainStyledAttributes(attrs, R.styleable.CustomView, 0, defStyleAttr) val boolean = a.getBoolean(R.styleable.CustomAttribute_customBoolean, false) val color = a.getColor(R.styleable.CustomAttribute_customColorValue, R.color.colorPrimary) val dimension = a.getDimension(R.styleable.CustomAttribute_customDimension, 20F) val float = a.getFloat(R.styleable.CustomView_attr_float, 20f) val fraction = a.getFraction(R.styleable.CustomView_attr_fraction, 1, 2, 0f) val integer = a.getInteger(R.styleable.CustomAttribute_customIntegerValue, 0) val string = a.getString(R.styleable.CustomView_attr_string) resourceId = a.getResourceId(R.styleable.CustomAttribute_customReference, R.drawable.meitu13333) var textPos = a.getInteger(R.styleable.CustomView_attr_enum, 0) a.recycle()