Answers for "changing button background color android"

1

material ui change button to custom color

/* 
style={{backgroundColor: '#12824C', color: '#FFFFFF'}}
backgroundColor changes the button color 
color changes the text color
These examples use Hex to define the color (Green button with white text)
*/

// Example
import React from 'react';
import Button from '@material-ui/core/Button';

const GreenButton = () => {
  return(
    <Button 
    style={{backgroundColor: '#12824C', color: '#FFFFFF'}}
    >Green</Button>
  )
}

export default GreenButton;
Posted by: Guest on January-05-2021
2

raisedbutton background color

List<bool> _list = [true, false, true, false];

@override
Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(title: Text("Title")),
    body: ListView(children: _buildButtons()),
  );
}

List<Widget> _buildButtons() {
  List<Widget> listButtons = List.generate(_list.length, (i) {
    return RaisedButton(
      color: _list[i] ? Colors.green : Colors.red,
      onPressed: () {
        setState(() {
          _list[i] = !_list[i];
        });
      },
      child: Text("Button #${i}"),
    );
  });
  return listButtons;
}
Posted by: Guest on June-25-2020

Code answers related to "changing button background color android"

Browse Popular Code Answers by Language