Make activity match current system dialog? - android

I'd like to be able to create an Activity that matches a default system Dialog. So in Android 2.2, it'll look like a Dialog for that version, in 2.3 it'll look like a Dialog for 2.3, etc.
The usual answer starts off with set android:theme="#android:style/Theme.Dialog" in the Activity manifest. However, that just gives you a floating box with unstyled text. What's missing is a title over a title bar, the dialog text, and the dialog buttons---all styled to match a system Dialog. What system styles should I use?
For example, I found TextAppearance_DialogWindowTitle in R.style. This gives you the text size for the title. Still missing is styling the title background, the buttons, etc.. Any ideas? Android style and theme documentation is sorely lacking.
I would just use the dialog builder except that I need to use a custom icon, so I would be back to square one styling a custom dialog....

Related

Custom Support Dialog Fragment text is the wrong color

If I put a TextView in a custom dialog box, the text will be black by default.
Unfortunately, the support fragment dialogs backgrounds are dark gray. Black on gray is very hard to read.
I could change the TextView to white or something like android:textColor="?android:attr/textColorPrimaryInverseDisableOnly".
But the dialog boxes on the new android (Holo Light) are white. So it will be white on white.
I could use a hack like forcing it to be white on old versions of Android and forcing it to be black on newer versions of Android, but I'd rather find a more elegant solution.
Is there a way to change the TextView to imitate the same text that's normally put on the support DialogFragment? I'm using Action Bar Sherlock, if that matters.
Try this
alertDialogBuilder.setInverseBackgroundForced( true )
works fine in my case on pre-Honeycomb devices and newer ones. The title still appears in a darker color but the main text is clearly readable on all devices.
If you're using ActionBarSherlock, I'm guessing you're supporting old devices as well. Sad thing about it is that old phones won't display any Holo Dialog, only old ugly Dialogs (and on many phones, they'll also be heavily customized by manufacturer). Therefore can't assume your Dialog will be Light.
There's only 2 things you can do :
Leave it as is and let the system handle the style of your Dialog
Set a custom view to your Dialog. Check here :
DialogFragment : Using AlertDialog with custom layout

Is it possible to style AlertDialog independently of activity's theme?

I realize the question is kind of weird, but I want to stop using deprecated options menu and switch to action bar. Unfortunately, to do that I must use Holo theme, which comes with a different AlertDialog design that was before.
This new design breaks my UI appearance. Is it possible to create an old-styled dialog in a Holo-styled activity?
Arelated question: is there any thing other than AlertDialog that is a pop-up window capable of showing my own layout, and that doesn't have borders and other theme-defined stuff around my custom layout?
Depending on the minSDKVersion set in your AndroidManifest file you can choose a theme for your dialog. You can set them to Holo / Device Default but to do that your minSdk value should be 10+ even I think that to use DeviceDefault it should be JellyBean.
If you want to create your own layout and use it without any borders and etc which will break your design you should use Dialog instead of AlertDialog and customize it. You can do something like this :
final Dialog alert = new Dialog(FingerPaintActivity.this, android.R.style.Theme_Light_Panel);
alert.requestWindowFeature(Window.FEATURE_NO_TITLE); // no title
alert.getWindow().getAttributes().windowAnimations = R.style.PauseDialogAnimation; // this is used for custom animation when dialog is showing and hiding
alert.setContentView(getLayoutInflater().inflate(R.layout.stamps, null)); // here is your custom layout
alert.getWindow().setLayout(width-50, (height-100)); // set height / width
and when you want to trigger an onlclick in your button for example which is placed in R.layout.stamps as in the example you should do like this :
Button dog = (Button) alert.findViewById(R.id.dog_stamp);
You can create a custom AlertDialog.
For example : http://www.mkyong.com/android/android-custom-dialog-example/

Customize the Search Dialog

I'm trying to add consistent selectors to my application. Similar to the drawable/list_selector. I can do this for all list elements and buttons in my application. But when it comes to system tasks such as the menu and the search, I can't find a way to style these. I have read the hack to style the menu, so this question is geared more towards the search dialog.
My Goal:
I want to style the Search Dialog that appears when the search button is pressed. Specifically I would like to change the outline color of the text box and also change the color of the text box when it is in a pressed state.
Any ideas would help.
Haven't tried any code, my thought was to add styles the searchable.xml file but I feel it doesn't work like that.

Dialog themed activity with action bar

In a v3 android application, is it possible for an activity that has a dialog theme (e.g.: Theme.Holo.Dialog) to have an action bar? I tried adjusting the windowIsFloating Attribute, but that caused an exception along the lines of "actionbarimpl not compatible", indicating that the current dialog theme does not support action bars?
It should be possible as several applications on the Samsung Galaxy Tab have dialogs with action bars.
Thanks.
The Dialog Theme wasn't designed to display an ActionBar.
Read this for more information.
When using a Dialog you want the user to choose between different options and make some decisions. I don't know what your Use-Case is but you better change your UI-Design so that you can manage your use-case with another solution. A solution Android was designed for.
If you really want to use a Dialog with a ActionBar, you can create your own by using a
Custom Dialog with a custom layout and build a ActionBar clone-layout.

Spinner pop up window title background

I would like to modify the background of the title bar of the dropdown dialog associated to a spinner.
If this is not possible I would like to know what resource is used to draw this background android.R.drawable.* ?
This is an effort of uniformity for my various pop ups in my application.
You can change everything using styles and themes.
Take a look at this example for buttons:
http://blog.androgames.net/40/custom-button-style-and-theme/

Categories

Resources