package skin.support.widget; import android.content.Context; import android.util.AttributeSet; import com.zhy.autolayout.AutoRelativeLayout; import skin.support.widget.SkinCompatBackgroundHelper; import skin.support.widget.SkinCompatSupportable; /** * Created by pengfengwang on 2017/3/15. */ public class SkinAutoRelativeLayout extends AutoRelativeLayout implements SkinCompatSupportable { private SkinCompatBackgroundHelper mBackgroundTintHelper; public SkinAutoRelativeLayout(Context context) { this(context, null); } public SkinAutoRelativeLayout(Context context, AttributeSet attrs) { this(context, attrs, 0); } public SkinAutoRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mBackgroundTintHelper = new SkinCompatBackgroundHelper(this); mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr); } public SkinAutoRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); mBackgroundTintHelper = new SkinCompatBackgroundHelper(this); mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr); } @Override public void setBackgroundResource(int resid) { super.setBackgroundResource(resid); if (mBackgroundTintHelper != null) { mBackgroundTintHelper.applySkin(); } } @Override public void applySkin() { if (mBackgroundTintHelper != null) { mBackgroundTintHelper.applySkin(); } } }