Trouble with Android UI: main theme does not match with popups' theme - android

So I am still working on my messaging app, and I have successfully implemented a few popups on my own, but then they don't turn out exactly as I want...
The theme is supposed to be strictly black text on white background, zero transparency (Theme.Light.NoTitleBar). While I have no problems whatsoever in the activity itself, my trouble is with the popups, whose theme does not seem to match as I expected. Can anybody tell me how to fix these?

It looks like after much trial and error, I only had to force the views to use specific styles/themes.
For the popup menu (PopupWindow):
menu.setBackgroundDrawable(getResources().getDrawable(
android.R.color.background_light));
For the dialog (DialogFragment), it's...:
setStyle(android.R.style.Widget_ListView, android.R.style.Theme_NoTitleBar);
...Or it just corrected itself.

Related

How to avoid the white screen before first activity is shown?

When opening my app for the first time, i can see a white screen for two or three seconds. After that, the first activity is shown.
¿How to avoid this annoying white screen? I'm pretty sure it's caused by the theme Theme.AppCompat.Light.DarkActionBar which I'm using.
I'm using this new theme because I'm using a NavigationView with a PagerTitleStrip and in the documentation of google they where using this theme to develop this kind of views.
How can i avoid that annoying white screen? If that screen can be for example black, it is munch better and munch less annoying. Can its color be changed? Has this theme a black version but without losing compatibility with a NavigationView with a PagerTitleStrip?
Thank you.
On your xml that you are using for your splashscreen add
android:opacity="opaque"
As cricket_007 tell in the comments, it is possible to get black color theme instead of Light simply using "Theme.AppCompat"
Also as CommonsWare tell us, too in the comments, it is a good practice to search if you are doing too much work in the main thread and use threads to get a fast ui load.
Thank you guys

Error indicators (for form validations) not shown for android 4.2?

Background
On Android, you can set an error indication for any EditText view when you want to show the user that what is typed there (or not typed) is wrong (called "form validations").
There is even a nice library for this (here) , and many post here are available of how to use it.
All worked well for me till I've ran it on a nexus 4 with Android 4.2 .
The problem
Sometimes, it just won't show the icons of the errors. In such a case , only when i give the editText (that has the problem) focus, it shows the bubble, but it's empty and doesn't show the icon of the error.
Also, in all cases, the bubbles are always empty.
Why does it occur, and how can I fix it?
Note: I use actionBarSherlock library so I need to use their themes or a theme that is based on theirs.
EDIT:
here are some screenshots:
android 4.2.2 :
android 2.3.5 :
EDIT:
after i thought that this was solved by itself, i've finally figured out when this bug occurs:
if the focus is on another editText which doesn't have an error, and the error of validation is on another editText , the indicator isn't shown till the editText gets focus.
Problem 1: The problem is the Theme of the application.
Try changing the theme to some darker theme like:
<style name="AppBaseTheme" parent="android:Theme.Black">
and it should solve your problem. I found this similar issue earlier and rectified this by changing the theme.
But I didn't research much but I feel that this is Android issue and the bubble should try to change the text colour according to the theme.
Let me know if it solves your problem, or not.
Problem 2: The other issue you are talking about for not taking focus, you may consider the following link: Text Truncating and Focus Issue.
----------------------------------------Updated Answer---------------------------------------------
Q1) What should I add to the theme configuration in order for it to always work, no matter what theme I use?
According to my findings here are some results:
[Note: Only applicable for devices running 3.0 and up]
If your build target is:
less than 11, then using
parent="android:Theme.Light" --> setError() message doesn't work or shows very faded text colour almost blending with color white
parent="android:Theme" --> setError() message works
greater than 11, then using
parent="android:Theme.Holo.Light" --> setError() message works
parent="android:Theme.Holo" --> setError() message works
Since, your project is supported for devices less than 11 API level and you want to support 4.0 and plus too, your best bet would be to go and integrate HoloEverywhere in your project which will solve your problem and you will be able to use your ActionBarSherlock too, for compatibility, check this SO Post.
Q2) What are the available configurations for the error indication UI ?
Mostly you can customise drawables and icons but I doubt you will be able to configure your text and background(If anyone knows more may point out on this)
I would suggest you to check this SO Post for immediate answers.
And for placing the correct focus, for every validation checks, you may place this code:
EditText.setFocusableInTouchMode(true);
EditText.requestFocus();
EditText.setError("My Error Text");
Let me know for any issues.

Can't see the text in SearchView widget suggestions

I think my SearchView widget population is working. However, all I see in the suggestions list are white text blocks. When I select one of the white blocks I see an orange highlight and I see the text behind the orange highlight. So it seems I'm showing white text and white background in my suggestions list. Any ideas on how to change that?
It doesn't look like you can customize your searchView. You could try setting the backgroundcolor of your searchview to (Color.WHITE).
I had exactly the same issue. I found that the root cause of the issue is related to theme I selected when creating the Android application project in Eclipse. I was using Android API 14, and originally I selected theme as None. I searched the web extensively and did not find an answer or even a similar question about this issue, which made me think that this is a very uncommon issue (most of people don't run into this issue). So I decide to create a new Android Project, with exactly the same components and set up, this time, only changed the theme from None to "Hollow Light with Dark Action Bar", suddenly, my search view suggestion drop down texts started to become visible. Now I went back to my original project, in AndroidManifest.xml, under Application tag, set android:theme="#android:style/Theme.Holo.Light.DarkActionBar", the search view suggestion drop down texts start to become visible in my old project now.

Tips for making the Android launcher transparent

I'm designing a custom Android 4.0 (ICS) device for special purpose.
One of the things I'm looking for is a way to make the Android Launcher, when other activities were previously running, show the last running activity as a transparent, dimmed background, with the launcher icons and widgets on top.
What I'm looking for, is something like this: How do I create a transparent Activity on Android?, except as a modification to Launcher2. I guess I can apply a similar style to the launcher as proposed in that SO, but what about the wallpaper?
AFAIU, the wallpaper is rendered by a separate service, and I still want it rendered if there are no other activities behind the launcher.
Any tips?
I figured this one out myself eventually. It turned out pretty simple.
Just modify the theme as suggested in the mentioned SO-article, and simply change inheritance from the Wallpaper-enabled theme.
Also, there were a small code-snippet that was reactivating the wallpaper. Switch that out, and I've now got a transparent launcher, that shows what's going on behind it.

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:
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.
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!
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.
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.
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.

Categories

Resources