{"id":613,"date":"2021-04-08T18:25:56","date_gmt":"2021-04-08T12:55:56","guid":{"rendered":"https:\/\/askadmin.com\/?p=613"},"modified":"2021-04-08T18:30:27","modified_gmt":"2021-04-08T13:00:27","slug":"alert-dialog-in-theme-appcompat-daynight","status":"publish","type":"post","link":"https:\/\/askadmin.com\/aa\/alert-dialog-in-theme-appcompat-daynight\/","title":{"rendered":"Alert dialog in Theme.AppCompat.DayNight"},"content":{"rendered":"<p>When we use <a href=\"https:\/\/developer.android.com\/guide\/topics\/ui\/look-and-feel\/darktheme\">Theme.AppCompat.DayNight\u00a0<\/a> on android , we may want to\u00a0 customise\u00a0 alert dialog window background , text and buttons color .Just define\u00a0 a seperate style for alert\u00a0 dialog in your\u00a0 style xml like below .<\/p>\n<p>&nbsp;<\/p>\n<pre>&lt;style name=\"CustomDialogStyle\" parent=\"Theme.AppCompat.DayNight.Dialog.Alert\"&gt;\r\n\r\n    &lt;!-- buttons --&gt;\r\n    &lt;item name=\"colorAccent\"&gt;#00FF00&lt;\/item&gt;\r\n    &lt;!-- title and text --&gt;\r\n    &lt;item name=\"android:textColorPrimary\"&gt;#000000&lt;\/item&gt;\r\n    &lt;!-- background you can change some other color than white --&gt;\r\n    &lt;item name=\"android:background\"&gt;#FFFFFF&lt;\/item&gt;\r\n     &lt;!-- change if you want below --&gt;\r\n    &lt;item name=\"android:textColor\"&gt;@null&lt;\/item&gt;\r\n    &lt;item name=\"android:textSize\"&gt;@null&lt;\/item&gt;\r\n&lt;\/style&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>and then call it like<\/p>\n<pre>AlertDialog dialog =\r\n        new AlertDialog.Builder(this, R.style.CustomDialogStyle)<\/pre>\n<p>For style.xml(night) you can define different style like below<\/p>\n<pre>&lt;style name=\"CustomDialogStyle\" parent=\"Theme.AppCompat.DayNight.Dialog.Alert\"&gt;\r\n\r\n    &lt;!-- buttons --&gt;\r\n    &lt;item name=\"colorAccent\"&gt;#00FF00&lt;\/item&gt;\r\n    &lt;!-- title and text --&gt;\r\n    &lt;item name=\"android:textColorPrimary\"&gt;#FFFFFF&lt;\/item&gt;\r\n    &lt;!-- background you can change to some other color than black--&gt;\r\n    &lt;item name=\"android:background\"&gt;#000000&lt;\/item&gt;\r\n     &lt;!-- change if you want below --&gt;\r\n    &lt;item name=\"android:textColor\"&gt;@null&lt;\/item&gt;\r\n    &lt;item name=\"android:textSize\"&gt;@null&lt;\/item&gt;\r\n&lt;\/style&gt;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>When we use Theme.AppCompat.DayNight\u00a0 on android , we may want to\u00a0 customise\u00a0 alert dialog window background , text and buttons color .Just define\u00a0 a seperate style for alert\u00a0 dialog in your\u00a0 style xml like below . &nbsp; &lt;style name=&#8221;CustomDialogStyle&#8221; parent=&#8221;Theme.AppCompat.DayNight.Dialog.Alert&#8221;&gt; &lt;!&#8211; buttons &#8211;&gt; &lt;item name=&#8221;colorAccent&#8221;&gt;#00FF00&lt;\/item&gt; &lt;!&#8211; title and text &#8211;&gt; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[142],"tags":[191,189,192,190],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v18.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Alert dialog in Theme.AppCompat.DayNight - Ask Admin - A Lifelong Learner<\/title>\n<meta name=\"description\" content=\"When you are using Dark mode theme for alert dialog Text may not be appearing as you want . You can customise alert dialog style\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/askadmin.com\/aa\/alert-dialog-in-theme-appcompat-daynight\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Alert dialog in Theme.AppCompat.DayNight - Ask Admin - A Lifelong Learner\" \/>\n<meta property=\"og:description\" content=\"When you are using Dark mode theme for alert dialog Text may not be appearing as you want . You can customise alert dialog style\" \/>\n<meta property=\"og:url\" content=\"https:\/\/askadmin.com\/aa\/alert-dialog-in-theme-appcompat-daynight\/\" \/>\n<meta property=\"og:site_name\" content=\"Ask Admin - A Lifelong Learner\" \/>\n<meta property=\"article:published_time\" content=\"2021-04-08T12:55:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-04-08T13:00:27+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"balu sreekanth\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/askadmin.com\/aa\/#website\",\"url\":\"https:\/\/askadmin.com\/aa\/\",\"name\":\"Ask Admin - A Lifelong Learner\",\"description\":\"Mobile App Development | IP Telephony | Linux\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/askadmin.com\/aa\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/askadmin.com\/aa\/alert-dialog-in-theme-appcompat-daynight\/#webpage\",\"url\":\"https:\/\/askadmin.com\/aa\/alert-dialog-in-theme-appcompat-daynight\/\",\"name\":\"Alert dialog in Theme.AppCompat.DayNight - Ask Admin - A Lifelong Learner\",\"isPartOf\":{\"@id\":\"https:\/\/askadmin.com\/aa\/#website\"},\"datePublished\":\"2021-04-08T12:55:56+00:00\",\"dateModified\":\"2021-04-08T13:00:27+00:00\",\"author\":{\"@id\":\"https:\/\/askadmin.com\/aa\/#\/schema\/person\/e1ff95d4a91ea001e25af3273533a345\"},\"description\":\"When you are using Dark mode theme for alert dialog Text may not be appearing as you want . You can customise alert dialog style\",\"breadcrumb\":{\"@id\":\"https:\/\/askadmin.com\/aa\/alert-dialog-in-theme-appcompat-daynight\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/askadmin.com\/aa\/alert-dialog-in-theme-appcompat-daynight\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/askadmin.com\/aa\/alert-dialog-in-theme-appcompat-daynight\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/askadmin.com\/aa\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Alert dialog in Theme.AppCompat.DayNight\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/askadmin.com\/aa\/#\/schema\/person\/e1ff95d4a91ea001e25af3273533a345\",\"name\":\"balu sreekanth\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/askadmin.com\/aa\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6aebf95935573dc70f536f1003a2fb8c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6aebf95935573dc70f536f1003a2fb8c?s=96&d=mm&r=g\",\"caption\":\"balu sreekanth\"},\"sameAs\":[\"http:\/\/askadmin.com\"],\"url\":\"https:\/\/askadmin.com\/aa\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Alert dialog in Theme.AppCompat.DayNight - Ask Admin - A Lifelong Learner","description":"When you are using Dark mode theme for alert dialog Text may not be appearing as you want . You can customise alert dialog style","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/askadmin.com\/aa\/alert-dialog-in-theme-appcompat-daynight\/","og_locale":"en_US","og_type":"article","og_title":"Alert dialog in Theme.AppCompat.DayNight - Ask Admin - A Lifelong Learner","og_description":"When you are using Dark mode theme for alert dialog Text may not be appearing as you want . You can customise alert dialog style","og_url":"https:\/\/askadmin.com\/aa\/alert-dialog-in-theme-appcompat-daynight\/","og_site_name":"Ask Admin - A Lifelong Learner","article_published_time":"2021-04-08T12:55:56+00:00","article_modified_time":"2021-04-08T13:00:27+00:00","twitter_misc":{"Written by":"balu sreekanth","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/askadmin.com\/aa\/#website","url":"https:\/\/askadmin.com\/aa\/","name":"Ask Admin - A Lifelong Learner","description":"Mobile App Development | IP Telephony | Linux","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/askadmin.com\/aa\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/askadmin.com\/aa\/alert-dialog-in-theme-appcompat-daynight\/#webpage","url":"https:\/\/askadmin.com\/aa\/alert-dialog-in-theme-appcompat-daynight\/","name":"Alert dialog in Theme.AppCompat.DayNight - Ask Admin - A Lifelong Learner","isPartOf":{"@id":"https:\/\/askadmin.com\/aa\/#website"},"datePublished":"2021-04-08T12:55:56+00:00","dateModified":"2021-04-08T13:00:27+00:00","author":{"@id":"https:\/\/askadmin.com\/aa\/#\/schema\/person\/e1ff95d4a91ea001e25af3273533a345"},"description":"When you are using Dark mode theme for alert dialog Text may not be appearing as you want . You can customise alert dialog style","breadcrumb":{"@id":"https:\/\/askadmin.com\/aa\/alert-dialog-in-theme-appcompat-daynight\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/askadmin.com\/aa\/alert-dialog-in-theme-appcompat-daynight\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/askadmin.com\/aa\/alert-dialog-in-theme-appcompat-daynight\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/askadmin.com\/aa\/"},{"@type":"ListItem","position":2,"name":"Alert dialog in Theme.AppCompat.DayNight"}]},{"@type":"Person","@id":"https:\/\/askadmin.com\/aa\/#\/schema\/person\/e1ff95d4a91ea001e25af3273533a345","name":"balu sreekanth","image":{"@type":"ImageObject","@id":"https:\/\/askadmin.com\/aa\/#personlogo","inLanguage":"en-US","url":"https:\/\/secure.gravatar.com\/avatar\/6aebf95935573dc70f536f1003a2fb8c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6aebf95935573dc70f536f1003a2fb8c?s=96&d=mm&r=g","caption":"balu sreekanth"},"sameAs":["http:\/\/askadmin.com"],"url":"https:\/\/askadmin.com\/aa\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/askadmin.com\/aa\/wp-json\/wp\/v2\/posts\/613"}],"collection":[{"href":"https:\/\/askadmin.com\/aa\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/askadmin.com\/aa\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/askadmin.com\/aa\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/askadmin.com\/aa\/wp-json\/wp\/v2\/comments?post=613"}],"version-history":[{"count":2,"href":"https:\/\/askadmin.com\/aa\/wp-json\/wp\/v2\/posts\/613\/revisions"}],"predecessor-version":[{"id":615,"href":"https:\/\/askadmin.com\/aa\/wp-json\/wp\/v2\/posts\/613\/revisions\/615"}],"wp:attachment":[{"href":"https:\/\/askadmin.com\/aa\/wp-json\/wp\/v2\/media?parent=613"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/askadmin.com\/aa\/wp-json\/wp\/v2\/categories?post=613"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/askadmin.com\/aa\/wp-json\/wp\/v2\/tags?post=613"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}