private void getAttributes(TypedArray array) {
        Resources res = getContext().getResources();
        cornerSize = array.getDimensionPixelSize(R.styleable.ChatBalloon_cb_corner_size, -1);
        if (cornerSize >= 0) {
            cornerSizeLeftBottom = cornerSize;
            cornerSizeLeftTop = cornerSize;
            cornerSizeRightBottom = cornerSize;
            cornerSizeRightTop = cornerSize;
        } else {
            // 默认
            int size = res.getDimensionPixelOffset(R.dimen.hlklib_chat_balloon_corner_size);
            cornerSizeLeftBottom = array.getDimensionPixelSize(R.styleable.ChatBalloon_cb_corner_size_left_bottom, size);
            cornerSizeLeftTop = array.getDimensionPixelSize(R.styleable.ChatBalloon_cb_corner_size_left_top, size);
            cornerSizeRightBottom = array.getDimensionPixelSize(R.styleable.ChatBalloon_cb_corner_size_right_bottom, size);
            cornerSizeRightTop = array.getDimensionPixelSize(R.styleable.ChatBalloon_cb_corner_size_right_top, size);
        }
        arrowWidth = array.getDimensionPixelSize(R.styleable.ChatBalloon_cb_arrow_width, res.getDimensionPixelOffset(R.dimen.hlklib_chat_balloon_arrow_width));
        arrowHeight = array.getDimensionPixelSize(R.styleable.ChatBalloon_cb_arrow_height, res.getDimensionPixelOffset(R.dimen.hlklib_chat_balloon_arrow_height));
        // 箭头默认在右侧上方
        arrowSide = array.getInteger(R.styleable.ChatBalloon_cb_arrow_side, RIGHT_TOP);
        arrowMargin = array.getDimensionPixelOffset(R.styleable.ChatBalloon_cb_arrow_margin, res.getDimensionPixelOffset(R.dimen.hlklib_chat_balloon_arrow_margin));
        backgroundNormal = array.getColor(R.styleable.ChatBalloon_cb_background_normal, Color.WHITE);
        backgroundActive = array.getColor(R.styleable.ChatBalloon_cb_background_active, ContextCompat.getColor(getContext(), R.color.hlklib_chat_balloon_active_color));
        borderSize = array.getDimensionPixelSize(R.styleable.ChatBalloon_cb_border_size, res.getDimensionPixelOffset(R.dimen.hlklib_chat_balloon_border_size));
        borderNormal = array.getColor(R.styleable.ChatBalloon_cb_border_normal, ContextCompat.getColor(getContext(), R.color.hlklib_chat_balloon_active_color));
        borderActive = array.getColor(R.styleable.ChatBalloon_cb_border_active, Color.WHITE);

        padding = gotExistedPadding();
    }
private void getAttributes ( TypedArray array ) { Resources res = getContext ( ) . getResources ( ) ; cornerSize = array . getDimensionPixelSize ( R . styleable . ChatBalloon_cb_corner_size , - 1 ) ; if ( cornerSize >= 0 ) { cornerSizeLeftBottom = cornerSize ; cornerSizeLeftTop = cornerSize ; cornerSizeRightBottom = cornerSize ; cornerSizeRightTop = cornerSize ; } else { int size = res . getDimensionPixelOffset ( R . dimen . hlklib_chat_balloon_corner_size ) ; cornerSizeLeftBottom = array . getDimensionPixelSize ( R . styleable . ChatBalloon_cb_corner_size_left_bottom , size ) ; cornerSizeLeftTop = array . getDimensionPixelSize ( R . styleable . ChatBalloon_cb_corner_size_left_top , size ) ; cornerSizeRightBottom = array . getDimensionPixelSize ( R . styleable . ChatBalloon_cb_corner_size_right_bottom , size ) ; cornerSizeRightTop = array . getDimensionPixelSize ( R . styleable . ChatBalloon_cb_corner_size_right_top , size ) ; } arrowWidth = array . getDimensionPixelSize ( R . styleable . ChatBalloon_cb_arrow_width , res . getDimensionPixelOffset ( R . dimen . hlklib_chat_balloon_arrow_width ) ) ; arrowHeight = array . getDimensionPixelSize ( R . styleable . ChatBalloon_cb_arrow_height , res . getDimensionPixelOffset ( R . dimen . hlklib_chat_balloon_arrow_height ) ) ; arrowSide = array . getInteger ( R . styleable . ChatBalloon_cb_arrow_side , RIGHT_TOP ) ; arrowMargin = array . getDimensionPixelOffset ( R . styleable . ChatBalloon_cb_arrow_margin , res . getDimensionPixelOffset ( R . dimen . hlklib_chat_balloon_arrow_margin ) ) ; backgroundNormal = array . getColor ( R . styleable . ChatBalloon_cb_background_normal , Color . WHITE ) ; backgroundActive = array . getColor ( R . styleable . ChatBalloon_cb_background_active , ContextCompat . getColor ( getContext ( ) , R . color . hlklib_chat_balloon_active_color ) ) ; borderSize = array . getDimensionPixelSize ( R . styleable . ChatBalloon_cb_border_size , res . getDimensionPixelOffset ( R . dimen . hlklib_chat_balloon_border_size ) ) ; borderNormal = array . getColor ( R . styleable . ChatBalloon_cb_border_normal , ContextCompat . getColor ( getContext ( ) , R . color . hlklib_chat_balloon_active_color ) ) ; borderActive = array . getColor ( R . styleable . ChatBalloon_cb_border_active , Color . WHITE ) ; padding = gotExistedPadding ( ) ; }
获取初始化属性