Setting alpha of ColorDrawable does not workAlpha blending a red, blue, and green image to produce an image tinted to any rgb value?Android and setting alpha for (image) view alphaSprite Batch doesn't change AlphaSVG fill color transparency / alpha?Set TextView style (bold or italic)ScrollView : Change the edge effect color with HoloMy colors are getting messed up when I give them an alpha valuealpha value always reset after color change of paintGLSL alpha test optimized out on NVIDIAIn JS, find the color as if it had 0.5 opacity on a white background?
Received email from ISP saying one of my devices has malware
What is a "fat pointer" in Rust?
Can there be plants on the dark side of a tidally locked world?
Punishment in pacifist society
Are there any writings by blinded and/or exiled Byzantine emperors?
Are manifolds admitting a circle foliation covered by manifolds with a (non-trivial) circle action?
Does immunity to non magical damage negate sneak attack damage?
Divide Numbers by 0
What do I do when a crotchet is above a minim?
How to run a command 1 out of N times in Bash
My boss says "This will help us better view the utilization of your services." Does this mean my job is ending in this organisation?
How does Harry wear the invisibility cloak?
What percentage of the mass/energy of the universe is in the form of electromagnetic waves?
Remove ads in Viber for PC
Visiting girlfriend in the USA
Does the Scrying spell require you to have a clear path to the target in order to work?
Why did the VIC-II and SID use 6 µm technology in the era of 3 µm and 1.5 µm?
Is it rude to ask my opponent to resign an online game when they have a lost endgame?
In Toy Story, are toys the only inanimate objects that become alive? And if so, why?
How do I stop making people jump at home and at work?
If the UK government illegally doesn't ask for article 50 extension, can parliament do it instead?
Why do old games use flashing as means of showing damage?
Were the women of Travancore, India, taxed for covering their breasts by breast size?
Importance of electrolytic capacitor size
Setting alpha of ColorDrawable does not work
Alpha blending a red, blue, and green image to produce an image tinted to any rgb value?Android and setting alpha for (image) view alphaSprite Batch doesn't change AlphaSVG fill color transparency / alpha?Set TextView style (bold or italic)ScrollView : Change the edge effect color with HoloMy colors are getting messed up when I give them an alpha valuealpha value always reset after color change of paintGLSL alpha test optimized out on NVIDIAIn JS, find the color as if it had 0.5 opacity on a white background?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am trying to achieve an effect in my app of where the user scrolls down, the opacity of a view will change from 0 to 1.
To achieve this, I've created a ColorDrawable with my desired color, blue, and then set its alpha to 0.
val actionBarBackground = ColorDrawable(ContextCompat.getColor(it, R.color.myBlue))
(activity as? AppCompatActivity)?.supportActionBar?.setBackgroundDrawable(actionBarBackground)
However, after increasing the alpha, it does not change. I've tried printing the value of actionBarBackground but its still 0...
// This is called inside a scrollview callback that calculates an alpha value between 0 and 255
actionBarBackground.alpha = 255
Log.d(TAG, "Alpha: $actionBarBackground.alpha") // Prints: Alpha: 0
Any ideas why the alpha of the ColorDwarable
does not change? Thank you.
android kotlin alpha colordrawable
add a comment |
I am trying to achieve an effect in my app of where the user scrolls down, the opacity of a view will change from 0 to 1.
To achieve this, I've created a ColorDrawable with my desired color, blue, and then set its alpha to 0.
val actionBarBackground = ColorDrawable(ContextCompat.getColor(it, R.color.myBlue))
(activity as? AppCompatActivity)?.supportActionBar?.setBackgroundDrawable(actionBarBackground)
However, after increasing the alpha, it does not change. I've tried printing the value of actionBarBackground but its still 0...
// This is called inside a scrollview callback that calculates an alpha value between 0 and 255
actionBarBackground.alpha = 255
Log.d(TAG, "Alpha: $actionBarBackground.alpha") // Prints: Alpha: 0
Any ideas why the alpha of the ColorDwarable
does not change? Thank you.
android kotlin alpha colordrawable
It might be nice if you add the tag for the language you are using (presumably Kotlin ?). See ColorDrawable setAlpha.
– Jon Goodwin
Mar 21 at 15:47
Thank you @JonGoodwin I've added the Kotlin tag. I've read the documentation of multiple times, and the.setAlpha()
function does not seem to change the value in the color drawable.
– Lucas P.
Mar 21 at 15:51
See kotlin docs. mutate and invalidateself and setAlpha. This looks WRONG in your questionactionBarBackground.alpha = 255
something likeactionBarBackground.setAlpha(255)
?
– Jon Goodwin
Mar 21 at 16:34
1
Thnk you Jon. In kotlin, getters and setters are automatically transformed into properties, so.setAlpha(255)
in kotlin is just.alpha = 255
. Even Android Studio suggests this change, when you use the normal setAlpha. However, you were right about.mutate()
. Using it, and replacing my ColorDrawable with the mutated Drawable returned, the alpha change works fine. Thank you for the help!
– Lucas P.
Mar 27 at 9:42
add a comment |
I am trying to achieve an effect in my app of where the user scrolls down, the opacity of a view will change from 0 to 1.
To achieve this, I've created a ColorDrawable with my desired color, blue, and then set its alpha to 0.
val actionBarBackground = ColorDrawable(ContextCompat.getColor(it, R.color.myBlue))
(activity as? AppCompatActivity)?.supportActionBar?.setBackgroundDrawable(actionBarBackground)
However, after increasing the alpha, it does not change. I've tried printing the value of actionBarBackground but its still 0...
// This is called inside a scrollview callback that calculates an alpha value between 0 and 255
actionBarBackground.alpha = 255
Log.d(TAG, "Alpha: $actionBarBackground.alpha") // Prints: Alpha: 0
Any ideas why the alpha of the ColorDwarable
does not change? Thank you.
android kotlin alpha colordrawable
I am trying to achieve an effect in my app of where the user scrolls down, the opacity of a view will change from 0 to 1.
To achieve this, I've created a ColorDrawable with my desired color, blue, and then set its alpha to 0.
val actionBarBackground = ColorDrawable(ContextCompat.getColor(it, R.color.myBlue))
(activity as? AppCompatActivity)?.supportActionBar?.setBackgroundDrawable(actionBarBackground)
However, after increasing the alpha, it does not change. I've tried printing the value of actionBarBackground but its still 0...
// This is called inside a scrollview callback that calculates an alpha value between 0 and 255
actionBarBackground.alpha = 255
Log.d(TAG, "Alpha: $actionBarBackground.alpha") // Prints: Alpha: 0
Any ideas why the alpha of the ColorDwarable
does not change? Thank you.
android kotlin alpha colordrawable
android kotlin alpha colordrawable
edited Mar 21 at 15:50
Lucas P.
asked Mar 21 at 15:26
Lucas P.Lucas P.
2,0411 gold badge13 silver badges21 bronze badges
2,0411 gold badge13 silver badges21 bronze badges
It might be nice if you add the tag for the language you are using (presumably Kotlin ?). See ColorDrawable setAlpha.
– Jon Goodwin
Mar 21 at 15:47
Thank you @JonGoodwin I've added the Kotlin tag. I've read the documentation of multiple times, and the.setAlpha()
function does not seem to change the value in the color drawable.
– Lucas P.
Mar 21 at 15:51
See kotlin docs. mutate and invalidateself and setAlpha. This looks WRONG in your questionactionBarBackground.alpha = 255
something likeactionBarBackground.setAlpha(255)
?
– Jon Goodwin
Mar 21 at 16:34
1
Thnk you Jon. In kotlin, getters and setters are automatically transformed into properties, so.setAlpha(255)
in kotlin is just.alpha = 255
. Even Android Studio suggests this change, when you use the normal setAlpha. However, you were right about.mutate()
. Using it, and replacing my ColorDrawable with the mutated Drawable returned, the alpha change works fine. Thank you for the help!
– Lucas P.
Mar 27 at 9:42
add a comment |
It might be nice if you add the tag for the language you are using (presumably Kotlin ?). See ColorDrawable setAlpha.
– Jon Goodwin
Mar 21 at 15:47
Thank you @JonGoodwin I've added the Kotlin tag. I've read the documentation of multiple times, and the.setAlpha()
function does not seem to change the value in the color drawable.
– Lucas P.
Mar 21 at 15:51
See kotlin docs. mutate and invalidateself and setAlpha. This looks WRONG in your questionactionBarBackground.alpha = 255
something likeactionBarBackground.setAlpha(255)
?
– Jon Goodwin
Mar 21 at 16:34
1
Thnk you Jon. In kotlin, getters and setters are automatically transformed into properties, so.setAlpha(255)
in kotlin is just.alpha = 255
. Even Android Studio suggests this change, when you use the normal setAlpha. However, you were right about.mutate()
. Using it, and replacing my ColorDrawable with the mutated Drawable returned, the alpha change works fine. Thank you for the help!
– Lucas P.
Mar 27 at 9:42
It might be nice if you add the tag for the language you are using (presumably Kotlin ?). See ColorDrawable setAlpha.
– Jon Goodwin
Mar 21 at 15:47
It might be nice if you add the tag for the language you are using (presumably Kotlin ?). See ColorDrawable setAlpha.
– Jon Goodwin
Mar 21 at 15:47
Thank you @JonGoodwin I've added the Kotlin tag. I've read the documentation of multiple times, and the
.setAlpha()
function does not seem to change the value in the color drawable.– Lucas P.
Mar 21 at 15:51
Thank you @JonGoodwin I've added the Kotlin tag. I've read the documentation of multiple times, and the
.setAlpha()
function does not seem to change the value in the color drawable.– Lucas P.
Mar 21 at 15:51
See kotlin docs. mutate and invalidateself and setAlpha. This looks WRONG in your question
actionBarBackground.alpha = 255
something like actionBarBackground.setAlpha(255)
?– Jon Goodwin
Mar 21 at 16:34
See kotlin docs. mutate and invalidateself and setAlpha. This looks WRONG in your question
actionBarBackground.alpha = 255
something like actionBarBackground.setAlpha(255)
?– Jon Goodwin
Mar 21 at 16:34
1
1
Thnk you Jon. In kotlin, getters and setters are automatically transformed into properties, so
.setAlpha(255)
in kotlin is just .alpha = 255
. Even Android Studio suggests this change, when you use the normal setAlpha. However, you were right about .mutate()
. Using it, and replacing my ColorDrawable with the mutated Drawable returned, the alpha change works fine. Thank you for the help!– Lucas P.
Mar 27 at 9:42
Thnk you Jon. In kotlin, getters and setters are automatically transformed into properties, so
.setAlpha(255)
in kotlin is just .alpha = 255
. Even Android Studio suggests this change, when you use the normal setAlpha. However, you were right about .mutate()
. Using it, and replacing my ColorDrawable with the mutated Drawable returned, the alpha change works fine. Thank you for the help!– Lucas P.
Mar 27 at 9:42
add a comment |
2 Answers
2
active
oldest
votes
Thanks to @Jon Goodwin's comment, I finally fixed the problem.
For some reason, changing the alpha value on a ColorDrawable
in Kotlin, does not seem to have any effect (it used to work in Java).
However, replacing this ColorDrawable
with the Drawable
you get from calling .mutate()
on the ColorDrawable
, makes the alpha changes work.
My final, working code from my question:
val actionBarBackground = ColorDrawable(ContextCompat.getColor(it, R.color.myBlue)).mutate()
// Keep in mind that actionBarBackground now is a Drawable, not a ColorDrawable
(activity as? AppCompatActivity)?.supportActionBar?.setBackgroundDrawable(actionBarBackground)
actionBarBackground.alpha = 255
Log.d(TAG, "Alpha: $actionBarBackground.alpha") // Prints: Alpha: 255
// This also works when called form inside a ScrolView Listener, to fade the actionbar background.
1
Glad to help ;O)
– Jon Goodwin
Mar 27 at 15:13
add a comment |
I guess I should answer, as Lucas P. says:
However, replacing this
ColorDrawable
with theDrawable
you get from
calling .mutate() on theColorDrawable
, makes the alpha changes work.
But it is not for some reason, there is a reason:
mutate() added in API level 3
open fun mutate(): Drawable
A mutable BitmapDrawable still shares its Bitmap with any other
Drawable that comes from the same resource.
mutate()
Added in API level 3
public Drawable mutate ()
Make this drawable mutable. This operation cannot be reversed. A
mutable drawable is guaranteed to not share its state with any other
drawable. This is especially useful when you need to modify properties
of drawables loaded from resources. By default, all drawables
instances loaded from the same resource share a common state; if you
modify the state of one instance, all the other instances will receive
the same modification. Calling this method on a mutable Drawable will
have no effect.
reference mutate
Kotlin distinguishes between mutable and immutable collections, automatically --cool (if you know what that means).
An immutable class is a class whose state cannot be changed once it
has been created.
Mutability
Thank you for this detailed explanation! Also the article on Mutability was a great read!
– Lucas P.
Mar 28 at 12:24
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55283913%2fsetting-alpha-of-colordrawable-does-not-work%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks to @Jon Goodwin's comment, I finally fixed the problem.
For some reason, changing the alpha value on a ColorDrawable
in Kotlin, does not seem to have any effect (it used to work in Java).
However, replacing this ColorDrawable
with the Drawable
you get from calling .mutate()
on the ColorDrawable
, makes the alpha changes work.
My final, working code from my question:
val actionBarBackground = ColorDrawable(ContextCompat.getColor(it, R.color.myBlue)).mutate()
// Keep in mind that actionBarBackground now is a Drawable, not a ColorDrawable
(activity as? AppCompatActivity)?.supportActionBar?.setBackgroundDrawable(actionBarBackground)
actionBarBackground.alpha = 255
Log.d(TAG, "Alpha: $actionBarBackground.alpha") // Prints: Alpha: 255
// This also works when called form inside a ScrolView Listener, to fade the actionbar background.
1
Glad to help ;O)
– Jon Goodwin
Mar 27 at 15:13
add a comment |
Thanks to @Jon Goodwin's comment, I finally fixed the problem.
For some reason, changing the alpha value on a ColorDrawable
in Kotlin, does not seem to have any effect (it used to work in Java).
However, replacing this ColorDrawable
with the Drawable
you get from calling .mutate()
on the ColorDrawable
, makes the alpha changes work.
My final, working code from my question:
val actionBarBackground = ColorDrawable(ContextCompat.getColor(it, R.color.myBlue)).mutate()
// Keep in mind that actionBarBackground now is a Drawable, not a ColorDrawable
(activity as? AppCompatActivity)?.supportActionBar?.setBackgroundDrawable(actionBarBackground)
actionBarBackground.alpha = 255
Log.d(TAG, "Alpha: $actionBarBackground.alpha") // Prints: Alpha: 255
// This also works when called form inside a ScrolView Listener, to fade the actionbar background.
1
Glad to help ;O)
– Jon Goodwin
Mar 27 at 15:13
add a comment |
Thanks to @Jon Goodwin's comment, I finally fixed the problem.
For some reason, changing the alpha value on a ColorDrawable
in Kotlin, does not seem to have any effect (it used to work in Java).
However, replacing this ColorDrawable
with the Drawable
you get from calling .mutate()
on the ColorDrawable
, makes the alpha changes work.
My final, working code from my question:
val actionBarBackground = ColorDrawable(ContextCompat.getColor(it, R.color.myBlue)).mutate()
// Keep in mind that actionBarBackground now is a Drawable, not a ColorDrawable
(activity as? AppCompatActivity)?.supportActionBar?.setBackgroundDrawable(actionBarBackground)
actionBarBackground.alpha = 255
Log.d(TAG, "Alpha: $actionBarBackground.alpha") // Prints: Alpha: 255
// This also works when called form inside a ScrolView Listener, to fade the actionbar background.
Thanks to @Jon Goodwin's comment, I finally fixed the problem.
For some reason, changing the alpha value on a ColorDrawable
in Kotlin, does not seem to have any effect (it used to work in Java).
However, replacing this ColorDrawable
with the Drawable
you get from calling .mutate()
on the ColorDrawable
, makes the alpha changes work.
My final, working code from my question:
val actionBarBackground = ColorDrawable(ContextCompat.getColor(it, R.color.myBlue)).mutate()
// Keep in mind that actionBarBackground now is a Drawable, not a ColorDrawable
(activity as? AppCompatActivity)?.supportActionBar?.setBackgroundDrawable(actionBarBackground)
actionBarBackground.alpha = 255
Log.d(TAG, "Alpha: $actionBarBackground.alpha") // Prints: Alpha: 255
// This also works when called form inside a ScrolView Listener, to fade the actionbar background.
answered Mar 27 at 9:48
Lucas P.Lucas P.
2,0411 gold badge13 silver badges21 bronze badges
2,0411 gold badge13 silver badges21 bronze badges
1
Glad to help ;O)
– Jon Goodwin
Mar 27 at 15:13
add a comment |
1
Glad to help ;O)
– Jon Goodwin
Mar 27 at 15:13
1
1
Glad to help ;O)
– Jon Goodwin
Mar 27 at 15:13
Glad to help ;O)
– Jon Goodwin
Mar 27 at 15:13
add a comment |
I guess I should answer, as Lucas P. says:
However, replacing this
ColorDrawable
with theDrawable
you get from
calling .mutate() on theColorDrawable
, makes the alpha changes work.
But it is not for some reason, there is a reason:
mutate() added in API level 3
open fun mutate(): Drawable
A mutable BitmapDrawable still shares its Bitmap with any other
Drawable that comes from the same resource.
mutate()
Added in API level 3
public Drawable mutate ()
Make this drawable mutable. This operation cannot be reversed. A
mutable drawable is guaranteed to not share its state with any other
drawable. This is especially useful when you need to modify properties
of drawables loaded from resources. By default, all drawables
instances loaded from the same resource share a common state; if you
modify the state of one instance, all the other instances will receive
the same modification. Calling this method on a mutable Drawable will
have no effect.
reference mutate
Kotlin distinguishes between mutable and immutable collections, automatically --cool (if you know what that means).
An immutable class is a class whose state cannot be changed once it
has been created.
Mutability
Thank you for this detailed explanation! Also the article on Mutability was a great read!
– Lucas P.
Mar 28 at 12:24
add a comment |
I guess I should answer, as Lucas P. says:
However, replacing this
ColorDrawable
with theDrawable
you get from
calling .mutate() on theColorDrawable
, makes the alpha changes work.
But it is not for some reason, there is a reason:
mutate() added in API level 3
open fun mutate(): Drawable
A mutable BitmapDrawable still shares its Bitmap with any other
Drawable that comes from the same resource.
mutate()
Added in API level 3
public Drawable mutate ()
Make this drawable mutable. This operation cannot be reversed. A
mutable drawable is guaranteed to not share its state with any other
drawable. This is especially useful when you need to modify properties
of drawables loaded from resources. By default, all drawables
instances loaded from the same resource share a common state; if you
modify the state of one instance, all the other instances will receive
the same modification. Calling this method on a mutable Drawable will
have no effect.
reference mutate
Kotlin distinguishes between mutable and immutable collections, automatically --cool (if you know what that means).
An immutable class is a class whose state cannot be changed once it
has been created.
Mutability
Thank you for this detailed explanation! Also the article on Mutability was a great read!
– Lucas P.
Mar 28 at 12:24
add a comment |
I guess I should answer, as Lucas P. says:
However, replacing this
ColorDrawable
with theDrawable
you get from
calling .mutate() on theColorDrawable
, makes the alpha changes work.
But it is not for some reason, there is a reason:
mutate() added in API level 3
open fun mutate(): Drawable
A mutable BitmapDrawable still shares its Bitmap with any other
Drawable that comes from the same resource.
mutate()
Added in API level 3
public Drawable mutate ()
Make this drawable mutable. This operation cannot be reversed. A
mutable drawable is guaranteed to not share its state with any other
drawable. This is especially useful when you need to modify properties
of drawables loaded from resources. By default, all drawables
instances loaded from the same resource share a common state; if you
modify the state of one instance, all the other instances will receive
the same modification. Calling this method on a mutable Drawable will
have no effect.
reference mutate
Kotlin distinguishes between mutable and immutable collections, automatically --cool (if you know what that means).
An immutable class is a class whose state cannot be changed once it
has been created.
Mutability
I guess I should answer, as Lucas P. says:
However, replacing this
ColorDrawable
with theDrawable
you get from
calling .mutate() on theColorDrawable
, makes the alpha changes work.
But it is not for some reason, there is a reason:
mutate() added in API level 3
open fun mutate(): Drawable
A mutable BitmapDrawable still shares its Bitmap with any other
Drawable that comes from the same resource.
mutate()
Added in API level 3
public Drawable mutate ()
Make this drawable mutable. This operation cannot be reversed. A
mutable drawable is guaranteed to not share its state with any other
drawable. This is especially useful when you need to modify properties
of drawables loaded from resources. By default, all drawables
instances loaded from the same resource share a common state; if you
modify the state of one instance, all the other instances will receive
the same modification. Calling this method on a mutable Drawable will
have no effect.
reference mutate
Kotlin distinguishes between mutable and immutable collections, automatically --cool (if you know what that means).
An immutable class is a class whose state cannot be changed once it
has been created.
Mutability
answered Mar 28 at 2:31
Jon GoodwinJon Goodwin
7,3994 gold badges23 silver badges49 bronze badges
7,3994 gold badges23 silver badges49 bronze badges
Thank you for this detailed explanation! Also the article on Mutability was a great read!
– Lucas P.
Mar 28 at 12:24
add a comment |
Thank you for this detailed explanation! Also the article on Mutability was a great read!
– Lucas P.
Mar 28 at 12:24
Thank you for this detailed explanation! Also the article on Mutability was a great read!
– Lucas P.
Mar 28 at 12:24
Thank you for this detailed explanation! Also the article on Mutability was a great read!
– Lucas P.
Mar 28 at 12:24
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55283913%2fsetting-alpha-of-colordrawable-does-not-work%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
It might be nice if you add the tag for the language you are using (presumably Kotlin ?). See ColorDrawable setAlpha.
– Jon Goodwin
Mar 21 at 15:47
Thank you @JonGoodwin I've added the Kotlin tag. I've read the documentation of multiple times, and the
.setAlpha()
function does not seem to change the value in the color drawable.– Lucas P.
Mar 21 at 15:51
See kotlin docs. mutate and invalidateself and setAlpha. This looks WRONG in your question
actionBarBackground.alpha = 255
something likeactionBarBackground.setAlpha(255)
?– Jon Goodwin
Mar 21 at 16:34
1
Thnk you Jon. In kotlin, getters and setters are automatically transformed into properties, so
.setAlpha(255)
in kotlin is just.alpha = 255
. Even Android Studio suggests this change, when you use the normal setAlpha. However, you were right about.mutate()
. Using it, and replacing my ColorDrawable with the mutated Drawable returned, the alpha change works fine. Thank you for the help!– Lucas P.
Mar 27 at 9:42