EditText field appearence - android

The EditText fields in the Android emulator have an inner shadow and rounded corners. The same app on my Samsung Galaxy shows the EditText fields flat looking and perfectly rectangular.
I realize there are differences between the versions of Android but is there a way to influence these properties of EditText fields?

In most cases it is better to use the default style, this is what the user expects.

You can completely define the look of your UI fields. If you want a fully custom look, go for a 9-patch background image. You can also define a look with xml drawable resources, which allow for rounded corners and gradients.
If you define the look, it will look that way on all phones. the highly variable UI changes between manufacturers and carriers is, in my opinion, one of the most frustrating issues with Android.
Most clients we have worked with has a complete UI spec. While there is an argument for using "the default", most commercial apps do not. At least for the style stuff. I would still argue that menus, notifications, preferences, etc should be Android standard.

Related

Is there something similar to Android's XML Drawables in iOS?

I'm currently creating a "design language" for my company which includes custom drawables for buttons, sliders, etc. Basically the idea is that I want our apps on Android and iOS to look and feel as similar as possible.
I started on Android and created XML drawables for buttons with simple borders and rounded corners, etc. Because I'm using XML, I can easily change things like the line thickness, radius dimension, and color with a single change. Other files reference things like #dimen/default_thickness, etc.
Is there any kind of similar concept on iOS? What I'd like to do is recreate these UI elements on iOS "dynamically" so that I don't have to create image files for each element. This would make it harder when one app uses one color for objects and another uses something else.
Basically what I want to know is this: Is there any way, with iOS, to create drawable resources dynamically instead of using static, pre-rendered images?
First,
No there is no XML for adding style to buttons or other views.
Second, you can implement the same type of design process by creating a constants file using NSObject, and then just add custom functions, variables for creating buttons... Something like:
+(UIButton *)create_styled_btn(float corner_width, UIColor color) {
....
return btn;
}
And of course you can dynamically change the style of objects through code, just like in android. XML in Android is of course static, so maybe I'm reading your question incorrectly.
All the best.

Android: Naming Resources

This is a question for Android developers but it is not a programming-related question as it affects nothing but the developer.
What conventions are the most commonly used when naming various resources like colors, drawables and strings and etc?
I have no doubts naming my layouts activity_main or layout_secondary. However, I have always doubts when naming resources mentioned previously. I never know whether I should name these resources after their use or the content. For example:
Color: dark_blue vs text_highlighted
Drawable: blue_gradient vs top_bar_background
String: welcome_to_app vs first_time_prompt
Is there any community-created resource for good practice?
Naming is pretty much personal preference. The name is perfect as long as the name indicates what the functionality of the defined thing is. Also you and any other developer using these definitions should know how what the names mean and which definition to choose. Quite easy if you are consistent with names throughout the project.
For example dark_blue is obviously a blue color while text_highlighted is the color of highlighted text. The name you should use depends on what you need: if you want to classify colors by their name take the first, if you like to abstract from the actual color take the second. For general layouts using text_highlighted will often make more sense since the actual color does not matter and the functionality (text highlight vs text regular etc.) is more important. In this example choosing between text_highlighted and text_regular is a lot more obvious than choosing between color_light_blue and color_dark_blue although they could refer to the same color. The name can help prevent errors.
Android uses prefixes for names in [android.R.drawable]
(http://developer.android.com/reference/android/R.drawable.html) for example:
btn_ for button graphics
ic_ for icon graphics
ic_menu_ for menu icons
ic_dialog_ for dialog icons
stat_ for status icons
The schema is certainly not perfect but the advantage of using prefixes that start with the most generic classification is that you can use code completion to search for specific items step by step. So color_blue_dark could be better than dark_blue_color, at least if you consider the color classification more important than the dark / light classification. The same applies to first_time_prompt. If you have a lot of prompts it would make sense to name them prompt_first_time, promt_other_time, ... If they can be classified by an activity for example that could be used as super category: mainactivity_prompt_*, secondactivity_prompt_* so you know where they belong to.
Android SDK will be a good place to start for the good practices. You can open up any sample code in the SDK and go through the code and see the variable names.
I usually name assets like colors and pictures for their content, but I will name a style or multiple state drawable for it's function.
for example:
button_On.png; button_Off.png; button.xml
That way if I want to use the same resource in multiple places it does not get confusing.
For example using a color as a text color in one style file and a background in another style file.

Create a custom style

I'm looking at how to give an app that I develop and deploy it's own look and feel. So I read about the Style and Themes on developer.android.com. After some initial success with text color, text size, background color... I seem to get stuck at changing buttons, toggle buttons... It appears to me that to change the color of a button a .9.png file must be created (possibly for the different dpi's). Looking at the artwork in the default style, I see a large number of these .9.png files. To have a consistent style they should all be updated.
Is it correct to say that defining a new style involves modifying/recreating the .9.png files?
If no, how should one go about modifying the style of these .9.png based elements?
If so, are there any tools that assist with creating a custom style? And are there any style packages that can be downloaded/purchased?
I'm not sure it's a good idea to give a new look to every UI control in your application unless you are a very experienced designer. Probably, we can't beat Google designers at their craft and it would be better to comply with existing styles adding some cool features instead of changing button colors at random.

Should I set my TextView colours if my background colour is not set?

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!

How to Get Android System Colors

I've seen references on how to SET system colours, but I need to find out how you GET them - how do you find out what they are?
On the Samsung Galaxy S for example, the tab views, ListView highlights when you select an item, and the Summary text line on the preference screen are all blue.
There are many apps which immitate this style and I want to do the same. Obviously I cannot just hard code and set the colour to Blue, as other handsets use different colours.
The question is, is there a way to programmatically find out what colour the Preference Screen Summary Line, Tabs, or ListView selections are, so that you can then set that against a TextView elsewhere in your app?
How do I get the android system colours?
There is an answer to this question, but it is probably not the one you wanted to hear. There is no way to reliably do this. The "selection color" is actually part of a nine-patch image, which is provided on a platform specific basis. Some use the standard orange color, some (Sense) uses green, and others use red. With an exhaustive list of these you might be able to create a mapping from hardware to color, but this is not very effective because new hardware comes out all the time, and some of these phones allow sense to be uninstalled.
The only real thing you can do is to make your buttons consistent within the application itself, which is a hard enough task by itself. If you really have to have a custom item with a selection color (which is common enough), then my advice would be to copy the button resources from the platform of your choice (I like the default sdk resources myself) and then manually set them throughout your application. This way they will always look the same no matter which platform you are on, and so will always match your custom views. Note that this will require you to do more than just buttons. Dialogs and menus also will need to be modified, which is possible, but hard.
Really this is a flaw in the way Android was designed, and it causes a lot of us grief. I wish I had a better answer for you, but I think this is the best we've got.
You can specify colours to elements in your XML layout using the #android:color system variable:
<TextView android:background="#android:color/white" android:textColor="#android:color/black" />

Categories

Resources