Can you please tell me why the android Contacts application theme/style is using 'dark' theme? For example, the activity's background is Black instead of White.
I have looked at their Android Manifest xml file and their layout xml file (e.g. call details.xml) file, but i don't see how they specified using a 'dark' theme?
Can you please tell me how do they do that? I have looked at http://developer.android.com/guide/topics/ui/themes.html, but I don't see Contacts app is doing that.
Thank you for any help.
The dark theme is the default in Android, if you do not specify otherwise.
Related
I am very new to app development and I am facing this error in issue panel in android studio
Failed to find '#attr/shapeAppearanceSmallComponent' in current theme
i am also facing a warning
Missing styles. Is the correct theme chosen for this layout?
After searching on web i found that this is caused by the wrong theme selected in AndroidManifest.xml.
So as i can understand this:
There is a file for every theme and have some values defined in it.
Theme is defined in AndroidManifest file, is a way to tell compiler that theme related values are saved in given file.
For me i have selected wrong theme file and my app is trying to find an attribute #attr/shapeAppearanceSmallComponent which it can't find because it is not available in theme passed in AndroidManifest.
My app want this attribute as i am using something which need this to be defined (maybe like material TextInputLayout).
Still this is my theory, i am no where near any answer
Now things i want to understand.
: Even if there is a problem in my application, i am still able to compile it and deploy on a device and it is running fine, In which case i can have issue because of this error.
If my theory is right than i have few questions:
If i am using some element (Button or EditText), how would i know that which theme does it support
What if i want elements from different themes to be used in a single application.
One more thing i observed is that in drop down menu in design view for activity_main.xml after changing the theme to Material3.dark from MaterialComponents removes the error.
error image
no error image
If i change theme in design layout using drop down menu it won't change automatically in Manifest file. So will it be true to say that changing themes using that drop down menu is just telling me, how my app will look using that theme, and if it is showing an error i shouldn't use that theme and use one which is not giving any kind of render error.
I will post my AndroidManifest or my activity_main if required
I am creating an app in android studio using java , I want to create a theme appearance setting like YouTube where user have 3 options to select one of them... 1) Use device theme 2) Dark theme 3) Light theme. But I don't know how to implement it in java activity and xml activity, can anyone help me ?
here I am attaching screenshot of what I want.
enter image description here
Here's a comprehensive description of how you might achieve that using XML layouts and styles: https://developer.android.com/guide/topics/ui/look-and-feel/darktheme
If you're completely new to XML theming in Android, then watch this video first: https://www.youtube.com/watch?v=Owkf8DhAOSo
It is calls Dialog with radiobuttons. All about it + implementation example - https://suragch.medium.com/adding-a-list-to-an-android-alertdialog-e13c1df6cf00
At the moment im using:
android:theme="#android:style/Theme.Black.NoTitleBar"
Which I'm growing a bit bored of, Is there a link you can direct me to that shows me examples of all the inbuilt themes and their names?
I read on another post that there is quite a few so it would be best if there was a website/other source that could show me some previews :)
Thanks for the help!
Your IDE (I know Android Studio does), should show you them.
Otherwise, here they are in raw xml form. https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/themes.xml
More information on Android Dev docs: http://developer.android.com/guide/topics/ui/themes.html
You can see all the theme names in the manifest.xml. For this see the following snapshot:
Android Studio has a Theme Editor which provides preview function.
User can find all built-in themes inside.
2 ways to open it:
Open a styles XML file, for instance res/values/styles.xml. Then click Open editor near the top-right of file-editing window.
in top menu bar Tools-Android-Theme Editor.
I'm pretty noobish with it all but basically I think there are only two themes. Day/Night and Light. You can select individual parts and change them but as far as I can tell there are only two themes.
As I had a comment that said this doesn't answer the question I will add that you can use Theme.AppCompat.DayNight or Theme.AppCompat.Light in the AndroidManifest.xml or in styles.xml and edit any individual attribute but there are about a million attributes and god only knows what they all do. In my opinion it's a massive oversite by android.
I am trying to apply my custom theme in the preference screen.
I got some hint from here(there are some Japanese but you can read the codes), but I don't know how to do it in ringtonepreference.
I got stuck in changing icons of ringtonepreference. I found they are #drawable/btn_circle
and #drawable/ic_btn_round_more, but couldn't find where can I override my images in theme.
Is there any way to do it? I think there should be some way with custom theme...
Would be grateful for any advice!
Does anyone know how I can find out what values are set in different Android themes? I know how to find the names of themes in the Graphical Layout view for a layout resource (Theme.Black, Theme.Light, Theme.Holo.Light, etc).
I want to find out the margins, color values, padding, and all that stuff for the different themes so I can make my app look consistent across devices whether they have a particular theme available or not.
You can get the information regarding the theme from the
#android:style/
So please Do it in your style.xml in value directory and you will get the default value of the style.
You can also add your custom style for any behaviour like theme or textAppearance or anything you want.
Also refer this.
Just refer it and you will get that values.
Hope it will help you.
Enjoy. :)
I think if you want to find the themes in certain device, you should get the source code of this device or decompile the framework-res.apk can also get styles.xml and themes.xml file. A lot of devices have changed the default themes, so if you want to make your app looks the same in different devices, the best way i think is to add android:theme in your AndroidManifest and refer to a self-build theme which does not inherit the system theme.