All posts in category "Android"

After a very frustrating evening and some really bad hacks, I fixed the theme for various dialogs (quick-info on longclicking a thumb and exif-info if you must know :)  ). For some reason we couldn’t find this very easily on the web, so why not share this information ;). Object? To make the dialog-background one color (so not only the background of the Views in your layout, but also that of the Title).

Steps:

1) Make a style. This is simply an XML file in the “values” dir, looking like this:

<?xml version="1.0" encoding="utf-8"?>
<resources>
	<style name="myBackgroundStyle" parent="@android:style/Theme.Dialog">
		<item name="android:background">#FF0000</item>
	</style>
</resources>

You can add this to your activity in the AndroidManifest.xml as “teh internetz” let us believe is the only way (maybe it was a googlefail on our side), but we’re going to do it the smart way:

2) Instead of the normal constructor, we’ll actually add the theme to the constructor.

Dialog myDialog = new Dialog(this,R.style.myBackgroundStyle);

And done. That was easy, wasn’t it?