CustomPicker Ok and Cancel buttons' color

后端 未结 3 1635
-上瘾入骨i
-上瘾入骨i 2021-01-23 16:16

I have this custompicker class in android project:

 public class CustomPickerRenderer : PickerRenderer
    {
        private Context context;
        private IEl         


        
相关标签:
3条回答
  • 2021-01-23 16:56

    add this style in style.xml

    <style name="SpinnerDialog" parent="Theme.AppCompat.Light.Dialog">
        <item name="android:popupBackground">#ff00ff</item>
        <item name="colorPrimary">#ff00ff</item>
        <item name="colorPrimaryDark">#ffff00</item>
        <item name="colorAccent">#ff0000</item>
    </style>
    

    you can change allthe color including buttons.

    and you can also use

     <style name="AlertDialogCustom" parent="android:Theme.Material.Light.Dialog.Alert">
        <item name="android:colorPrimary">#1e87f0</item>
        <item name="android:colorAccent">#1e87f0</item>
      </style>
    
      <style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
        <item name="colorAccent">#1e87f0</item>
      </style>
    
    0 讨论(0)
  • 2021-01-23 17:06

    The Question is answered here: Picker button's color not changing on android 5.1

    I added the styles code in the correct answer in the link, and it worked!

    0 讨论(0)
  • 2021-01-23 17:11

    Get the button object through the API of dialog and set the text color of the button. This method can be personalized. One point needs to be noted: it must be called after show

    in your custom renderer,below _dialog.Show();

    ....
    _dialog.Show();
    Button btnOk = _dialog.GetButton((int)DialogInterface.ButtonPositive);
    btnOk .SetTextColor(Color.Red);
    Button btnCancel= _dialog.GetButton((int)DialogInterface.ButtonNegative);
    btnCancel.SetTextColor(Color.Red);
    
    0 讨论(0)
提交回复
热议问题