-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change Android button background method #1296
Comments
Good idea |
Nice one @bradmartin - it is good to be able to change the color of the button without loosing the material design. |
We can use simply: var nativeColor = v.style._getValue(style.backgroundColorProperty).android;
nativeView.getBackground().setColorFilter(nativeColor, android.graphics.PorterDuff.Mode.SRC_IN); if only backgroundColor is set. In this way we can preserve other styles. |
Hi @enchev i'm sorry, how do i implement that code you showed. I have this issue where the button background-color is used as a tint, or has transparency... i want to remove that. i pasted that snippet in my app.js and it fails to compile saying "v" is not defined... i missed a require somewhere. |
@enchev I have the same question as @talvasconcelos, what is the "v" object referencing here? |
Think it's the view instance so the button. Not at computer to check the NativeScript view api but i think that's it |
@bradmartin Got it, that would make sense. |
In one of my views where I'm experiencing this problem I've tried the following:
Yet when I load that view I get the following error:
Should I be referencing a different "view" when calling getBackground()? I have tried a couple different things but none of them are working out. It seems if I set the border-width of the button with ID "create-btn" then that fixes the issue in Android 4.4 but then I lose the material design in all other versions. |
@enchev - Is this issue still on NativeScript team radar? |
Hey @calebeaires, This was fixed long time ago. Right now if you only want to set the color we will not override the default drawable. |
@enchev - Thanks for your help. May you just me give some more info? If I choose to use |
Those android API versions don't have material/ripple :) On Thu, Nov 10, 2016, 7:32 AM Calebe Aires notifications@github.com wrote:
|
Yep, @bradmartin is correct. You can only set the color if you want to keep the original drawable. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Change the button background styling from
to
I've done this programatically by creating a new android.widget.Button() and found no issues.
If this is possible without collision in other areas it would give the buttons their material design ripple effect, whereas setBackground removes the ripple effect. Will this open other issues. I didn't want to make a PR without knowing if there would be other issues or conflicts.
The text was updated successfully, but these errors were encountered: