To add the gradient background somebody suggest to use android:background and others say android:theme.
android: background will set the background in your current view/layout.
Themes on Android allow you to separate the details of your app design from the UI structure and behavior, similar to stylesheets in web design.
A theme is more of a collective thing which has its impact on overall UI of your screen. Like the color of the action bar, the color of the line in your edit text etc.
You can read more details about themes here.
Related
I am currently getting started with Material components themes. The Getting Started guide mentions these themes:
Theme.MaterialComponents
Theme.MaterialComponents.NoActionBar
Theme.MaterialComponents.Light
Theme.MaterialComponents.Light.NoActionBar
Theme.MaterialComponents.Light.DarkActionBar
Theme.MaterialComponents.DayNight
Theme.MaterialComponents.DayNight.NoActionBar
Theme.MaterialComponents.DayNight.DarkActionBar
There is no description for them though. Where can I find more details about those themes or could anyone be so kind to explain them in an answer? Just for example:
What means [..].NoActionBar? If I don't want an action bar, I don't include it in my layout file, so I really don't get this.
When would I use only Theme.MaterialComponents? Or would I always use Theme.MaterialComponents.Light or Theme.MaterialComponents.DayNight?
How do these themes look like? I couldn't find any preview and don't want to try them all out by myself - could take some time with all the widgets available on Android.
What do these themes define? Only colors? Text style? Font family?
I'm certain that I won't manage to answer all of your questions exhaustively but I'll share some thoughts, maybe it will take you one or two steps further:
What means [..].NoActionBar?
You should use a theme ending with ".NoActionBar" if you don't want the runtime to add an ActionBar to the Activity, possibly because you use a Toolbar. If you choose for example Theme.MaterialComponents.Light and use a Toolbar as well, you will notice that now your app will be renderd with two ActionBars
Please note that if some theme is called "MyTheme" then a theme which is prefixed by "MyTheme." will inherit everything from "MyTheme". So Theme.MaterialComponents.Light.NoActionBar is almost the same as Theme.MaterialComponents.Light except for the ActionBar.
So if you really don't want any ActionBar you should choose the .NoActionBar version and not include a surrogate (Toolbar) in your layout files.
What do these themes define? Only colors? Text style? Font family?
They do that, but they define also sizes, margins and behavior. In addition to that, some of them have special style combos for certain widgets (like style="#style/Widget.MaterialComponents.TextInputLayout.FilledBox" for TextInputLayout)
For a deep dive into what properties can be influenced by a theme, you can take a look at the source of themes_material.xml
When would I use only Theme.MaterialComponents? Or would I always use Theme.MaterialComponents.Light or Theme.MaterialComponents.DayNight?
Since Theme.MaterialComponents is the parent theme of Theme.MaterialComponents.Light, they have much in common. The main difference is that the first assumes that your app will have a dark background (so the text should be white) whereas the second will have black text and assumes your app's background will be light.
Generally, one will try to use a certain theme as a template which then can be/ has to be customized - for example with a special accent color.
How do these themes look like?
You can get a general idea by switching from one to the other in a small sample app of your own.
It's true that there is not one single source of information (aka the android theming bible). You have already found material.io, but maybe the Styles and Themes section from developer.android.com or this blog post on DayNight — Adding a dark theme to your app will shed some more light.
I'm trying to program my theme following Material Theming practice, and understand that primary color is the 'main' color throughout the app; secondary color, is something for floating button(FAB).
But I'm struggling to find out: What other UI components that primary_color|secondary_color should be applied upon for, in general?
I've looked on this link, but seems like those color concept is very dependable
https://material.io/design/color/applying-color-to-ui.html#
colorPrimary - The color of the app bar.
color secondary - light version of colorprimary
colorAccent - The color of UI controls such as check boxes, radio buttons, and edit text boxes.
So maybe this question should be tagged as design or material-design rather than android, that’s why people were kinda down voting me, which is pretty sad.. Not sure how inappropriate my question is to the down-voter... Anyway, I found out the closest answer to my question is:
Primary-color is used in almost all the material components, because it is used to illustrate color of your brand. So that can be used in multiple UI components such as:
background color: appbar, bottom bar or some screens
Headlines color
Title color
Selected state
etc.
For example, consider the Crane app show case can be found # Material Study: Crane, the icon background color, we can see it’s purple(suggestive brand home color). It could have primary_variant, i.e: ‘darker’ purple in the example.. BUT overall it’s used to demonstrate the unique color of the brand. Another example is Facebook should have primary color blue.
Secondary-color is used to illustrate important/informative actions and should be highlighted and constrast especially when it’s near primary-color, which maybe designed under:
FAB
Focused state for selective UI component
Headlines
Button text color
Highlight for the calendar
etc.
Some of the app may not have secondary color, for example, newspaper like NewYork Times app.
Finally, thinking in term of primary_color and secondary_color, is not about specifically which component should use the color, it’s about how we semantically lay out our app, in term of brand, communication, information.
Is there a way to replicate the color changing ability provided by QKSMS .
It allows a user to select a color and then changes the app color and everything to that color.This is all done dynamically the moment the user chooses a specific color.
You can try this cool online tool: http://android-holo-colors.com
This enables you to create many themes for app widgets with your preferred color. You can then change your app theme by saving values for your theme in SharesPreferences or something similar and apply them in onCreate of each activity you have in your app. You can also create the themes easily in styles.xml. For each view, it has its own style with its own attributes so you will need to learn how to edit the theme of each view you want by searching...
Hope that helps.
Some Examples:
ActionBar:
https://developer.android.com/training/basics/actionbar/styling.html
Buttons:
https://www.androidcookbook.com/Recipe.seam?recipeId=3307
SeekBar:
Android - styling seek bar
Switch:
How can I style an Android Switch?
And a lot more... You will have to search for what you want.
Im searching for an android gui-library with more components i could use in my app.
Example:
A microcontroller sends the rpm of a motor (via bluetooth) to my smartphone.
And i want to use my smartphone in order to show the received rpm in progressbar-like element.
But the normal progressbar looks ugly, and i would have to progressbar.setClickable(false); .
As i said before
Im searching a library with more gui-elements(optional: i could modify, customize the outward appearance on my own)
Do anybody of you know about such a library ?
Thanks so far.
If you're just concerned about the external appearance of your GUI elements, I don't think there's any support for different UI elements than the ones provided. However, have you looked into a universal Theme and style for your application?
Here are some excerpts from that document:
A style is a collection of properties that specify the look and format
for a View or window. A style can specify properties such as height,
padding, font color, font size, background color, and much more. A
style is defined in an XML resource that is separate from the XML that
specifies the layout.
A theme is a style applied to an entire Activity or application,
rather than an individual View (as in the example above). When a style
is applied as a theme, every View in the Activity or application will
apply each style property that it supports. For example, you can apply
the same CodeFont style as a theme for an Activity and then all text
inside that Activity will have green monospace font.
Here are some resources which talk about themes:
Mobile Orchard Article
Android Engineer Article
Let me know if that's what you wanted. Themes give you almost infinite possibilities to modify outwards appearance.
When I comes to specifying colours for an application, I recently came across #android:color. Is it recommended to try to always use predefined system colors?
I changed the colours of some of my labels to something brighter, so that they'll stand out against the black background. But then I start to wonder... would themes/skins (not familiar with those) and such cause the default background colour to be something other than black?
If so... what's the proper way to deal with colouring one's widgets?
(Disclaimer: I don't know Android. This is general UI design advice.)
If you set the foreground color, you should change the background color as well. Otherwise, if someone's background is set to something wacky, your labels could wind up invisible -- or at the least, hard to see -- and you'll have defeated the purpose of using different colors.
I'd recommend you leave the colors as they are, unless you can change the background color as well. Perhaps using a bold font or something would be a better idea.
You've got 2 options:
1) define explicitly fore/background colors of all of your elements
2) use only default colors, so when the user change its theme, everything will change accordingly. Personally, i prefer this way, but be careful if your UI's got some images
Be consistent, so you'll avoid issues when users change its themes. choose one and back to work!