I have an custom view which extends Button. And I just want to set the belove style to this view.
<style name="MultipleButtonStyle" parent="android:Widget.Material.Light.Spinner.Underlined">
<item name="android:textColor">@android:color/black</item>
<item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
</style>
To be able set style programmatically, I have tried some way. But They didn't work for me.
The First way, is using the style in the constructor of the custom button like this :
public class SpinnerButton extends AppCompatButton{
public SpinnerButton (Context context) {
super(context, null, R.style.MultipleButtonStyle);
}
}
Second way is use setTextAppearance
method. It didn't work me as well.
if (Build.VERSION.SDK_INT < 23) {
super.setTextAppearance(getContext(), R.style.MultipleButtonStyle );
} else {
super.setTextAppearance(R.style.MultipleButtonStyle);
}