Change the background color of a pop-up dialog
If you just want a light theme and aren't particular about the specific color, then you can pass a theme id to the AlertDialog.Builder constructor.
AlertDialog.Builder(this, AlertDialog.THEME_HOLO_LIGHT)...
or
AlertDialog.Builder(this, AlertDialog.THEME_DEVICE_DEFAULT_LIGHT)...
Change background color for the action section in Flutter alertDialog
Try below code hope its helpful to you.
Your Widget to call alrtDialog
TextButton(
onPressed: () {
showDataAlert();
},
child: Text(
'Pressed',
),
),
Your Alert Dialog function
showDataAlert() {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(
20.0,
),
),
),
contentPadding: EdgeInsets.only(
top: 10.0,
),
title: Text(
"Your Title Here",
style: TextStyle(fontSize: 24.0),
),
content: Container(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
"Your Contents Here",
style: TextStyle(fontSize: 24.0),
),
SizedBox(
height: 5.0,
),
Container(
decoration: BoxDecoration(
color: Colors.grey.shade500,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(20.0),
bottomRight: Radius.circular(20.0)),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
ElevatedButton(
onPressed: () {
Navigator.of(context).pop();
},
style: ElevatedButton.styleFrom(
primary: Colors.white,
),
child: Text(
"Cancel",
style: TextStyle(
color: Colors.black,
),
),
),
SizedBox(
width: 10,
),
ElevatedButton(
onPressed: () {
Navigator.of(context).pop();
},
style: ElevatedButton.styleFrom(
primary: Colors.black,
),
child: Text(
"Confirm",
),
),
],
),
)),
],
),
),
);
});
}
- Refer ElevatedButton here
- Refer AlertDialog here
Your Result Screen->
Flutter change dialog background color
You need to wrap your Dialog
in a Builder
like this. After that dialogBackgroundColor
will have an effect.
Theme(
data: ThemeData(dialogBackgroundColor: Colors.orange),
child: Builder(
builder: (context) {
return RaisedButton(
onPressed: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text("Dialog title"),
);
},
);
},
child: Text("Show dialog"),
);
},
),
)
How to change background color popup menu android
Add popupMenu style to ur AppTheme:
<style name="AppTheme" parent="android:Theme.Light">
<item name="android:popupMenuStyle">@style/PopupMenu</item>
</style>
<style name="PopupMenu" parent="@android:style/Widget.PopupMenu">
<item name="android:popupBackground">@android:color/white</item>
</style>
manifest.xml:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
.............
</application>
How to change the background color of pop up header?
Change color background
in .modalDialog > div
css.
.modalDialog > div {
width: 600px;
position: relative;
margin: 2% auto;
padding: 5px 20px 13px 20px;
border-radius: 5px;
background: red; //Here
height: 100%;
}
Fiddle
Edit:
If you want to change color of only header part then you should put one div parent to .pop-header
<div>
<div class="pop-header">
<a href="#close" title="Close" class="close">X</a>
</div>
And css:
.pop-header
{
width: 100%;
background-color: red;
height: 50px;
}
Updated Fiddle
Check as per your image
New Fiddle
Related Topics
How to Add Firebase-Admin to My Android Project
Update SQL Database with Contentvalues and the Update-Method
How to Integrate Opencv 4.0 into a Pure C++ Android Ndk Project
Android 4.0.1 Breaks Webview HTML 5 Local Storage
Disabling Android's Chrome Pull-Down-To-Refresh Feature
Why Does Flag_Activity_Clear_Top Not Work
What Is The Easiest Way to Use Svg Images in Android
Activity.Finish() Called But Activity Stays Loaded in Memory
In HTML5, How to Keep an Android Device's Screen On
Android Back Button on a Progressive Web Application Closes De App
Mediaplayer Stop Playing After About 5 Seconds
Android Collapsingtoolbarlayout Collapse Listener
HTML5 <Video> Element on Android Does Not Play