Is there any way to create a circular button in android without just setting drawable shape file as background? Because I want to set button color programmatically and by setting drawable shape file as background it doesn't work. I also used Floating action Button but when tried to set color swatch as background it didnt work.
`public class MainActivity extends AppCompatActivity implements View.OnClickListener {
FloatingActionButton fab1, fab2, fab3, fab4, fab5,fab6;
ImageView imgV;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
fab1 = (FloatingActionButton) findViewById(R.id.bt1);
fab2 = (FloatingActionButton) findViewById(R.id.bt2);
fab3 = (FloatingActionButton) findViewById(R.id.bt3);
fab4 = (FloatingActionButton) findViewById(R.id.bt4);
fab5 = (FloatingActionButton) findViewById(R.id.bt5);
fab6 = (FloatingActionButton) findViewById(R.id.bt6);
imgV = (ImageView) findViewById(R.id.imageView);
fab1.setOnClickListener(this);
fab2.setOnClickListener(this);
fab3.setOnClickListener(this);
fab4.setOnClickListener(this);
fab5.setOnClickListener(this);
Bitmap bitmap = ((BitmapDrawable) imgV.getDrawable()).getBitmap();
if (bitmap != null) {
Palette.from(bitmap).maximumColorCount(10).generate(new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(Palette palette) {
setViewSwatch(fab1, palette.getVibrantSwatch(), "Vibrant");
setViewSwatch(fab2, palette.getDarkVibrantSwatch(), "Dark Vibrant");
setViewSwatch(fab3, palette.getLightVibrantSwatch(), "Light Vibrant");
setViewSwatch(fab4, palette.getMutedSwatch(), "Muted");
setViewSwatch(fab5, palette.getLightMutedSwatch(), "Light Muted");
}
});
}
}
private void setViewSwatch(FloatingActionButton fab, Palette.Swatch vibrantSwatch, String vibrant) {
if (vibrantSwatch != null) {
fab.setBackgroundColor(vibrantSwatch.getRgb());
}
}
`