Reputation: 611
What is the difference between Theme.Material...
and Theme.MaterialComponents...
?
I am creating an alert dialogue and when I create it using:
new AlertDialog.Builder(context, android.R.style.Theme_Material_Light_Dialog_Alert);
I get "colorAccent" coloured text on the buttons.
However when I create the dialog using:
return new AlertDialog.Builder(context, R.style.myTheme);
with:
<style name="myTheme" parent="@style/Theme.MaterialComponents.Light.Dialog.Alert"/>
I seem to get purple coloured text. What is the difference between these?
And finally if I were to derive "myTheme" from Theme.AppCompat...
(instead of Theme.MaterialComponent...
) I get white text. What is going on here?
Upvotes: 2
Views: 1850
Reputation: 364391
The Theme.Material
is provided by Android starting with API 21.
The Theme.MaterialComponents
is provided by the Material Components library.
They are completely different.
If you want to use the Material Components Library the best way is to use the MaterialAlertDialogBuilder
.
return new MaterialAlertDialogBuilder(context, R.style.myTheme);
and inherit the theme overlay from:
<style name="myTheme" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
Here you can check all the default attributes applied to the theme.
Upvotes: 5