Home > Enterprise >  Are there any difference between `Widget.MaterialComponents.LinearProgressIndicator.MyStyleName` and
Are there any difference between `Widget.MaterialComponents.LinearProgressIndicator.MyStyleName` and

Time:12-28

Are there any difference between Widget.MaterialComponents.LinearProgressIndicator.MyStyleName and MyStyleName?

<style name="Widget.MaterialComponents.LinearProgressIndicator.MyStyleName" parent="Widget.MaterialComponents.LinearProgressIndicator">
    <item name="trackColor">@color/green</item>
    <item name="indicatorColor">@color/gray</item>
    <item name="android:indeterminate">true</item>
</style>

<style name="MyStyleName" parent="Widget.MaterialComponents.LinearProgressIndicator">
    <item name="trackColor">@color/green</item>
    <item name="indicatorColor">@color/gray</item>
    <item name="android:indeterminate">true</item>
</style>

And can I apply MyStyleName directly to linearProgressIndicator without using this line?

<item name="linearProgressIndicatorStyle">@style/MyStyleName</item>

CodePudding user response:

Only the style name is different, both styles are inheriting same parent style. Yes you can apply MystyleName directly to ur linearProgressIndicator by using style attribute like this :

style="@style/MyStyleName"

Add this line in the LinearProgressIndicator xml code.

  • Related