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

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.

Related

Android- Can we create material views programmatically?

Is it possible to create Material Design views (like button, textView, ...) programmatically?
like
AwesomeButton btnTest=new AwesomeButton (context);
i want full featured library like rey5137 but without XML usage and support old android(maybe Android 2.3 and up).
material design is all about different combinations of items in xml. you cannot design without xml. it is not java swing don't forget, whatever you want to design their base should be on drawable or layout folder, not on java code
update for the edited question
in your example, you say AwesomeButton, in order to have something like this, you need to have a library, which also has xml design file including all those fancy visual effects. If you don't design how are you supposed to create a pre-designed button.
chamran, you are making it complicated my friend, you can't design a button via code, you have to have a xml file for your own custom materials. Even the default button has a xml.

EditText field appearence

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.

How can I make a Android app look pretty?

When I place things like text boxes they are fixed in one position and I can't move them around easily.
How can I edit the style and maybe put an image at the top of the text boxes and give the app a neat and pretty little layout?
Thanks
Use RelativeLayouts instead of LinearLayouts (i assume that you are using them) which allow free positioning.
To modify the theme/colors, read Applying Styles and Themes.
Create 9-patch graphics and assign them as backgrounds.
I am unsure if this is what you are looking for,but you can arrange the object on the layout from the xml files in res/layouts/ folder.Do not forget to follow the UI guidelines provided by google for android development. Also you can create custom themes for you app if you do not like the default template.

Style Editor - dynamically create and apply styles

I'm developing an app for text reading. I'm trying to increase the options for my users to customize the appearance of the text and the app itself. Creating multiple styles in my resources folder and switching among them at runtime seems simple enough using the view constructors that take a style parameter.
However I'm also considering going one step further and creating a style editor in my application that allows users to have full control over their experience.
I think that doing this using Android styles is basically out of the question, since the style ids are generated at compile time. I'm considering creating custom views that are light wrappers around the views that I need styled, manipulating the AttributeSet in the view constructor to apply my styles.
How should I dynamically create and apply styles to my views?
your approach is quite right as i tried several posts in several places, if you don't do it yourself, it wont be done :-) Android does not support dynamic theme as it seems.
I wanted mine to be downloadable as a plugin, you need, as you say create a wrapper and be able to extract extra parameters from the AtrributeSet OR add an extra HashTable parameter with the attributes you want to override.

multiple drawables from one xml file

I want to use a number of ShapeDrawables in my application, which are all similar, but with different colours etc. Obviously I could just define them all in separate xml files, but is there a more efficient way to have one xml definition, instantiate various objects and change the colour either in code or xml? You could perhaps do this by calling mutate() on one ShapeDrawable defined in xml, but this returns a Drawable, rather than a shape drawable.
Maybe use GradientDrawable instead of ShapeDrawable.
Actually it is possible to do what you asked for,
this post shows you how to do it.
I tried it and it works perfectly. I haven't found though how to refer to a single drawable from the list.
It seems Level lists are meant to be used into a single object to represent different states of the object. Alhtough in this case we are using it as a drawable container to avoid having many small files.
Maybe future anrdroid releases will support a dedicated drawable container.

Categories

Resources