@@ -68,6 +68,11 @@ public LikeButton(Context context, AttributeSet attrs, int defStyleAttr) {
6868 * @param defStyle
6969 */
7070 private void init (Context context , AttributeSet attrs , int defStyle ) {
71+ LayoutInflater .from (getContext ()).inflate (R .layout .likeview , this , true );
72+ icon = (ImageView ) findViewById (R .id .icon );
73+ dotsView = (DotsView ) findViewById (R .id .dots );
74+ circleView = (CircleView ) findViewById (R .id .circle );
75+
7176 final TypedArray array = context .obtainStyledAttributes (attrs , R .styleable .LikeButton , defStyle , 0 );
7277
7378 iconSize = array .getDimensionPixelSize (R .styleable .LikeButton_icon_size , -1 );
@@ -77,19 +82,20 @@ private void init(Context context, AttributeSet attrs, int defStyle) {
7782 String iconType = array .getString (R .styleable .LikeButton_icon_type );
7883
7984 likeDrawable = array .getDrawable (R .styleable .LikeButton_like_drawable );
85+
86+ if (likeDrawable !=null )
87+ setLikeDrawable (likeDrawable );
88+
8089 unlikeDrawable = array .getDrawable (R .styleable .LikeButton_unlike_drawable );
8190
91+ if (unlikeDrawable !=null )
92+ setUnlikeDrawable (unlikeDrawable );
8293
8394 if (iconType != null )
8495 if (!iconType .isEmpty ())
8596 currentIcon = parseIconType (iconType );
8697
8798
88- LayoutInflater .from (getContext ()).inflate (R .layout .likeview , this , true );
89- icon = (ImageView ) findViewById (R .id .icon );
90- dotsView = (DotsView ) findViewById (R .id .dots );
91- circleView = (CircleView ) findViewById (R .id .circle );
92-
9399 circleStartColor = array .getColor (R .styleable .LikeButton_circle_start_color , 0 );
94100
95101 if (circleStartColor != 0 )
0 commit comments