eidylon
eidylon

Reputation: 7238

How do I use common UI styles in Android?

I am writing my little Android app. I pop up a dialog control which is a nice, non-fullscreen, rounded-corners dialog by setting android:theme="@android:style/Theme.Dialog" on the activity in my manifest. That all works just as I expected. However it is just a drab, grey-titled dialog as in this screenshot:

default grey dialog look

I've noticed however that a LOT of applications, when they pop up dialogs have a nice, blue-themed title as in this screen shot.

enter image description here

I would assume this theme is some common theme, as it shows up in a LOT of different apps. I would assume it is something built in to the OS. (My phone is a Captivate with the official Froyo release). Of course it COULD be something that every developer simply re-coded on their own, but I doubt that.

Assuming that this is a common theme, how do I utilize it in my app? What changes do I need to make to my activity to have it use that theme?

Thanks in advance!

Upvotes: 4

Views: 1536

Answers (3)

XurajB
XurajB

Reputation: 840

To make a dialog you need to extend the dialog class. And to have a nice title bar you can use:

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

and have your own custom title.

to have a title use:

setTitle("MyTitle");

You can also assign your custom view for the title.

Upvotes: 0

Femi
Femi

Reputation: 64700

Rather messy (there doesn't seem to be a good reference for this), but the platform styles are defined in \platforms\android-\data\res\values\styles.xml and \platforms\android-\data\res\values\themes.xml. You can dig through those and figure out the theme/style IDs that are available at compile time.

Other than that its really just trial and error.

Upvotes: 0

jkhouw1
jkhouw1

Reputation: 7350

You can set your activity to use a default theme like Theme.Black. There are default themes and they are in R.style - although i'm not sure which are available to which platforms(i.e. i think the holo themes are for 3.0 and up...

http://developer.android.com/reference/android/R.style.html

see here http://developer.android.com/guide/topics/ui/themes.html for defining your own custom themes and scroll all the way down for using the "platform styles" and themes.

Upvotes: 2

Related Questions