stepstone-tech / android-material-stepper

This library allows to use Material steppers inside Android applications.
Apache License 2.0
1.78k stars 262 forks source link

Having Issue applying style on StepperLayout #290

Open kevintorch opened 4 years ago

kevintorch commented 4 years ago

Styles are not applying on Stepper Layout. I've added "ms_stepperStyle" in main application theme as shown below.

`

<style name="AppTheme.Default">
    <item name="appBarLayoutBackground">?colorPrimary</item>
    <item name="ms_stepperStyle">@style/StepperStyle</item>
    <item name="bottomNavigationStyle">@style/Widget.eduCare.BottomNavigationView</item>
    <item name="toolbarIconTint">@color/appColorOnDarkSurfaceHighEmphasis</item>
    <item name="appTextColorPrimary">@color/white</item>
    <item name="toolbarStyle">@style/Widget.eduCare.Toolbar.Primary</item>
</style>

<style name="StepperStyle" parent="MSDefaultStepperLayoutTheme">
    <item name="ms_bottomNavigationStyle">@style/Widget.StepperStyle.BottomNavigation</item>
    <item name="ms_backNavigationButtonStyle">@style/Widget.StepperStyle.Button.Back</item>
    <item name="ms_nextNavigationButtonStyle">@style/Widget.StepperStyle.Button.Next</item>
    <item name="ms_completeNavigationButtonStyle">@style/Widget.StepperStyle.Button.Complete
    </item>
</style>

<style name="Widget.StepperStyle.BottomNavigation" parent="">
    <item name="android:layout_height">200dp</item>
    <item name="android:background">?colorSurface</item>
    <item name="elevation">16dp</item>
</style>

<style name="Widget.StepperStyle.Button" parent="Widget.eduCare.Button.TextButton" />

<style name="Widget.StepperStyle.Button.Back" parent="Widget.eduCare.Button.TextButton"></style>

<style name="Widget.StepperStyle.Button.Next"></style>

<style name="Widget.StepperStyle.Button.Complete">
    <item name="android:text">Save</item>
</style>

`

but the style is not being applied.

And here is StepperLayout

<com.stepstone.stepper.StepperLayout android:id="@+id/stepperLayout" android:layout_width="match_parent" android:layout_height="match_parent" app:ms_stepperType="dots" app:ms_activeStepColor="?appColorPrimaryDark" app:ms_errorColor="?appColorError" app:ms_completeButtonColor="?appColorPrimaryDark" app:ms_nextButtonColor="?appColorPrimaryDark" app:ms_backButtonColor="?appColorPrimaryDark" app:ms_backButtonBackground="@color/caldroid_transparent" app:ms_completeButtonText="Save Enquiry" app:ms_stepperLayoutTheme="?ms_stepperStyle" app:layout_behavior="@string/appbar_scrolling_view_behavior" />

if i add theme attribute to StepperLayout it crashes and gives me the error below:

layout/ms_stepper_layout: Binary XML file line 49: You must supply a layout_width attribute

Please Help

zawadz88 commented 4 years ago

Hi, It seems that you've mixed styles and themes a bit in here. ms_stepperStyle is used to set a global style in the app. In the code you posted you're assigning a theme to it though:

<style name="StepperStyle" parent="MSDefaultStepperLayoutTheme">

if you want to set a theme you should use ms_stepperLayoutTheme instead. I can see that you're setting via app:ms_stepperLayoutTheme="?ms_stepperStyle" so the one in AppTheme.Default should not be needed.

For a sample usage see: https://github.com/stepstone-tech/android-material-stepper/blob/master/sample/src/main/res/values/styles.xml AppThemeDark -> CustomStepperLayoutThemeSample -> DarkCustomStepperLayoutTheme

https://github.com/stepstone-tech/android-material-stepper#custom-styling