Change BackGroundColor of ButtonFlat
On Changing ButtonFlat's BackGroundColor from XML as well as from Code only Text's Font Color get changed instead of ButtonFlat's BackGroundColor.. So how do i can achieve this in ButtonFlat ? Expeting +ve & quick response..!!!
It seems that every background color you enter is overwritten in this line.
public ButtonFloat(Context context, AttributeSet attrs) { super(context, attrs); X-----> setBackgroundResource(R.drawable.background_button_float);
:(
Actually when defining the background property sets the rippleColor property. And when the rippleColor property is defined then the background property has no effect.
I noticed this behavior for the ButtonFloat too. It seems that setAttributes gets not called in the Constructor of ButtonFloat. Right now i get around by subclassing it and calling it in the Constructor. Maybe this helps here too.
public class MyButtonFloat extends ButtonFloat
{
public MyButtonFloat(final Context context, final AttributeSet attrs)
{
super(context, attrs);
setAttributes(attrs);
}
}
Edit: as @dilizarov pointed out i missed something (Thank you) : Now in your xml Layout change
com.gc.materialdesign.views.ButtonFloat
to
com.path.to.your.MyButtonFloat
@Gittner Thank you so much. That is awesome!
To anyone new to customizing these types of things, once you make Gittner's fix, head to your XML layout files and wherever you originally used the com.gc.materialdesign.views.ButtonFloat, just swap it out with com.path.to.your.MyButtonFloat. :)
@dilizarov you can also change color programmatically using setBackgroundColor
ButtonFlat is always transparent! if you want to use a rectangle button with background color you can use ButtonRectangle that is quite the same button but with coloured background