Reputation: 2568
Currently, I have something like this inside my view:
public void DisableNextBtn(object sender, TextChangedEventArgs e)
{
if (String.IsNullOrEmpty(emailentry.Text))
{
NextButton.IsEnabled = false;
NextButton.TextColor = Color.FromRgba(0xFF, 0xFF, 0xFF, 0x80);
}
else
{
NextButton.IsEnabled = true;
NextButton.TextColor = Color.White;
}
}
However, even though I want to set the TextColor of the button to the color above, it won't change from the default dark disabled state text color. How can I change the TextColor for my button?
I have a custom button already, so I was thinking maybe there is a way to change the textcolor of disabled state button inside my custom renderer but I'm not entirely sure.
This is for Xamarin.Forms Android app.
Upvotes: 3
Views: 6993
Reputation: 1
This might not be a workable solution for everybody, but in order to get around this I changed the MouseDownBackColor and MouseOverBackColor to match the setting I was using for the BackColor, this way I could leave the button enabled and use it just to display text with a transparent background as none of the text box components allow a transparent background to be used.
Upvotes: 0
Reputation: 385
if you'd like to change the color so it becomes like the color of it background, wich means you want to hide the text, you can do:
button1.Text = "";
button1.Enabled = true;
Upvotes: 0
Reputation: 3744
You can change it using NextButton.ForeColor = Color.FromRgba(0xFF, 0xFF, 0xFF, 0x80);
.
Upvotes: 0
Reputation: 116
In xamarin forms android, I just did this in my styles.xml
for my disabled textcolor
. I'm sure it's the same for button textcolor
.
<item name="android:textColor">@android:color/black</item>
Upvotes: 0
Reputation: 6981
mBtnEmail.setTextColor(ContextCompat.getColor(getContext(), R.color.text_gray));
Upvotes: 0