Skip to content

Instantly share code, notes, and snippets.

@abizareyhan
Created February 16, 2019 22:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save abizareyhan/fae820d968a326b1eee71a84a81d2da8 to your computer and use it in GitHub Desktop.
Save abizareyhan/fae820d968a326b1eee71a84a81d2da8 to your computer and use it in GitHub Desktop.
package com.abizareyhan;
import android.content.Context;
import android.graphics.drawable.GradientDrawable;
import android.support.v7.widget.AppCompatButton;
import android.util.AttributeSet;
import com.abizareyhan.reyplayground.R;
public class CustomizableButton extends AppCompatButton {
public CustomizableButton(Context context) {
super(context);
inisialisasi();
}
public CustomizableButton(Context context, AttributeSet attrs) {
super(context, attrs);
inisialisasi();
}
public CustomizableButton(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
inisialisasi();
}
public void inisialisasi(){
GradientDrawable shape = new GradientDrawable();
shape.setShape(GradientDrawable.RECTANGLE);
shape.setCornerRadius(100);
shape.setColor(getResources().getColor(R.color.colorPrimary));
setBackground(shape);
setTextColor(getResources().getColor(R.color.colorWhite));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment