-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an attribute for materialButtonOutlinedStyle
It's a common use case to want to mix up buttons with outlined buttons and an attribute facilitates reusing layouts with different themes. PiperOrigin-RevId: 234189427
- Loading branch information
Showing
5 changed files
with
10 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
991927f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello. I am dynamically generating Material Buttons onto my view. For some reason, I am able to pass
R.attr.materialButtonStyle
onto my three parameter constructor forMaterialButton()
but I am not able to passR.attr.materialButtonOutlinedStyle
onto the same. I have support design dependency and I also tried adding google material design dependency which did not work either. What am I missing here? Thanks991927f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this was added in version
1.1.0-alpha04
ofcom.google.android.material:material
. What version are you using?991927f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the thing, I do not have this dependency yet I am able to use
MaterialButton
in my xml layout. Using this dependency is not an option for me because it messes up my whole ui and the app does not compile because of a weird data binding error. Using the dependency, I also do not get the attribute that I have mentioned already.991927f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What version are you using?
Can you try our latest version (1.1.0-rc01) and provide more details about how the new version "messes up the whole ui" and causes a data binding error (stacktrace)?
991927f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I was developing the static layout for the app, I only had the support design dependency:
I have three buttons on my ui: at any given time, two of them will be outlined button and one of them have to be regular solid material button (all of them with corner radius)
So I achieve static UI with styling (two of them with
outlinedButtonStyle
and one withmaterialButtonStyle
declared in the XML). I did not have to use any dependency for material components (the one that you are talking about)Now when I have to make the buttons dynamic, I quickly find out that setting style dynamically is not supported on android. I tried Paris library by AirBNB but they do not currently support dynamic styling on MaterialComponents. Hence I have to now dynamically generate all three buttons with attributes and their positioning from kotlin code.
My problem currently is that I cannot pass
R.attr.materialButtonOutlinedStyle
onto myMaterialButton
constructor. Any way I can achieve my requirements using only attributes and not depending on thecom.google.android.material:material
?991927f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
materialButtonOutlinedStyle
attribute was introduced in thecom.google.android.material:material
library, so you would need to use that library to be able to use the attribute.In terms of dynamic styling, you could use a ContextThemeWrapper and a theme overlay:
991927f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dsn5ft Thank you very much for this. However, funnily enough I did not have to depend on
com.google.android.material:material
which works in my favor. :)