@Override
protected void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes){
mWidth = MATCH_PARENT;
mHeight = WRAP_CONTENT;
mDuration = -1;
mIsRtl = false;
mText = new TextView(context);
mText.setSingleLine(true);
mText.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
addView(mText, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
mAction = new Button(context);
mAction.setBackgroundResource(0);
mAction.setGravity(Gravity.CENTER);
mAction.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mActionClickListener != null)
mActionClickListener.onActionClick(SnackBar.this, mActionId);
dismiss();
}
});
addView(mAction, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
mBackground = new BackgroundDrawable();
mBackground.setColor(0xFF323232);
ViewUtil.setBackground(this, mBackground);
setClickable(true);
super.init(context, attrs, defStyleAttr, defStyleRes);
}