I am new to Android but not to Java. Is there already a little framework which allows me to create layouts, custom views and drawables programmatically using CSS sheets for padding, borders etc; just like Nimbus/Three20 for iOS ?
We've working on an "App-Studio" so all the views, lists etc. are rather dynamic, basing on the CSS the user created by a visual style template editor.
And if not, would you recommend to create such Android layout xml files on the fly and then load them from file, or is it better to create the drawables by hand ? We'can't bake such files just into the build because the user needs to be able to change the style in real-time on the device.
Thank you.
Partial ans only to:
And if not, would you recommend to create such Android layout xml files on the flyand then
load them from file, or is it better to create the drawables by hand ?
I dont think you can create layout xml files on the fly and load them in the running app. They have to be created prior to compilation of the app.
Android uses Styles and Themes. Reading about these will help you generate some common patterns which you can use in your context. Once you have some patterns you can create these xmls using some automation tool prior to compilation (and avoid writing them by hand...:), funny computer changed the definition of by hand).
Related
I want to store colors in a way that they can be used for both platforms.
I could create a class in the PCL or a shared project, but I am not finding a way to load a color from a xml file. Since we make xml files that are placed in the drawables they refer to colors like this way : #color/black
Is there a way to store the values of colours in a portable way for both platforms?
folks. I'm beginning Android development and all of the tutoring videos constantly mention XML file. I looked up the meaning of XML which says:"XML was designed to describe data." But WHY is XML needed in Android and in general(please explain in simple understandable words)? Is there any way to create projects w/o XML file? Thanks in advance!
According to Android documentation:
The advantage to declaring your UI in XML is that it enables you to better separate the presentation of your application from the code that controls its behavior. Your UI descriptions are external to your application code, which means that you can modify or adapt it without having to modify your source code and recompile. For example, you can create XML layouts for different screen orientations, different device screen sizes, and different languages. Additionally, declaring the layout in XML makes it easier to visualize the structure of your UI, so it's easier to debug problems.
Using Android's XML vocabulary, you can quickly design UI layouts and the screen elements they contain, in the same way you create web pages in HTML — with a series of nested elements.
Short answer. To make your life easier.
I've developped an application using XML Eclipse tool too build my UI.
Now, i'd like to use a tool like Axure to create a "nicer" interface.
My problem is : is there an easy way to switch from XML to HTML (because Axure is producting HTML file from Wireframe design) ?
And if not, how to "plug" HTML file to the existing application (which is using R.layout.xxx or R.id.xxx to access displayed elements).
I'm quite new in Android by the way...
thanks !
You can't really do what you describe. The way Android layout is specified in XML cannot be compared at all to HTML for websites. Besides, Axure is a mock-up tool. It creates interactive mockups and prototypes - not final solutions for anything.
If you really want to use Axure, perhaps you would want to go for web apps with something like PhoneGap - they are written in HTML and JavaScript, but have less possibilities.
Why can't HTML be used for building interface in Android Programing?
XML enables us to create custom tags.. Consider we created a custom view, we can reference them from xml itself. So the idea of UI separation from logics, stays intact.
HTML is a standard designed to display web pages. The android XML layout files are custom configuration files that are intended to be parsed by the dalvik VM. Two separate worlds. Here are some good reasons not to use HTML to define a configuration.
HTML is not well formed. Parsing is a pain. No schema checking.
How will you style elements ? CSS ?
Its hard enough getting CSS to work
across several browsers.
How will you introduce custom elements into
the HTML configuration ?
I could go on. It just does not make sense to configure a native UI using HTML.
I think the xml is chosen because the xml tags are defined in android according to the UI framework classes and the attributes are defined corresponding to the member variables of the class in the UI framework. This mapping was not possible for the html.
Extensible Markup Language, the extensible part makes it much more versatile. HTML is basically an implementation of the general concept of XML specifically for web browsers.
Also it is overly bloated for the simple task of creating layouts because it contains a lot of tags and attributes (i.e. method, onclick, etc.) that define the behavior of elements not just their layout.
I think they are few reasons for that:
When you have Layout and Source Code separately you can separate your application logic. Thus many XML files can be bound with one piece of source code and Platform (Android, Windows Phone, etc.) will choose automatically the proper XML layout depending for example on: screen denisity, screen orientation etc.
Next thing is answer to your question: Why not html. In my opinion there are few reasons. Most important is that XML has strict well formed structure and XML can be restricted with XML Schema. In fact having XML Schema is great because not also restrict your document but also give an sort of documentation of files inside XML. Someone reading this may think: HTML can have also strict structure as XHTML specification. Yes but XML is designed for that.
Next aspect is that XML is more popular as HTML in configuration/Layout (Java EE, XAML, Android XML's, etc.) stuff. It's like a good practise.
In fact you can build your application almost in HTML/JavaScript but you need to use some specific framework which wrappes your Platform application and transform it to Platfrom Independent Web Application(for example Sencha Framework)
I have several custom UI elements that are to be used in several projects. Each project will use the same UI elements but have a different looking front end.
eg: Background images for button types will be different depending on the project.
How do I package the UI classes and resources in such a way so that projects can use them while being able to modify the look and feel?
Use Android library project, that will be shared among multiple apps. Provide there default graphics.
When you provide customized graphics in your app for particular file in res folder, it will be used instead of default graphics in library. This way you can replace needed graphics set while using same code base.
Info:
https://developer.android.com/tools/projects/index.html#LibraryProjects