I tried to run my activity in full screen mode using this method:
android:theme="#android:style/Theme.NoTitleBar.Fullscreen
But after it my all design were changed. My Edittext-s which had only a line below now become rectangles and buttons design are changed too.
How to avoid this situation?
Try this theme instead:
android:theme="#android:style/Theme.Holo.Light.NoActionBar.Fullscreen"
The theme you are applying to your Activity is old and I think even deprecated. The Holo themes are the ones you are looking for.
Related
Trying to add Dark Mode to my app. I am mostly there, most things work as I expect after I made the required changes, however I have a problem with the Toolbar. What have I missed?
Screenshot of Toolbar issue, and layout
You're applying AppTheme to popupTheme, what does it have?
You don't usually need to make a custom one, one of the pre-made ones like ThemeOverlay.MaterialComponents.Toolbar is enough.
And actually, if you're using MaterialComponents, you don't need to apply anything to your app to make it work in Dark Mode, just use the DayNight MaterialComponents theme.
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
I have two buttons in my layout. They appear fine with padding around their sides. However, when I change the activity's theme to #android:style/Theme.Black.NoTitleBar
All of a sudden, the buttons become really small with no padding around them. Why is this happen? All it takes is for me to remove the theme attribute (remove NoTtitleBar) and that fixes them. What does that have to do with the buttons?
Need to use
android:theme="#android:style/Theme.Holo.NoActionBar"
instead. The one I was using before is for gingerbread and so it changes the default style of buttons, etc...
I have a ListView which should have the "Theme" theme in portrait and the "Theme.Light" theme in landscape mode. How do I do that? The theme seems to be tied to the activity, and for the ListView I can only change the style, but I dont find a style which works.
Or, is there a way to change the activity's theme based on orientation? By code or prefereable by xml?
To be more precise and explain the reason: I try to start experimenting with the fragment compatibility library. The starting activity shows in portrait mode a list which looks best with black background. When I touch a list item, a second Activity starts and shows a ListView which better looks on white, so this second Activity has the Theme.Light. Works so far.
When I switch to landscape, I try to show both ListViews aside. The second one on the right has to have a white background. The first one on the left could stay on white also (so the whole activity could change the theme), but I'd like to see one on black and one on white, if possible. (I put both ListViews in Fragments, this is done and works. Only the colors are wrong.)
Any ideas?
Greetings, Joerg
You would create a layout.xml file for each orientation, and put each in the proper folder according to the Android standards.
Then, you can set the different style as an attribute in each XML file.
Android will use the appropriate layout file automatically, depending on orientation.
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.