Does anyone know of any tools (besides DroidDraw) that can help me create the basics of my projects a bit quicker? I'm looking for something that will allow me to very quickly generate the XML for my layouts so I don't have to sit there typing like a robot for so long.
Thanks!
However the drag and drop layout design method is not recommended for Android Applications UI designers but there is an Open Source project on Google Code: android-ui-utils , in which you might find something intersiting.
It uses a Firefox addon Pencil to draw and design android layouts and also uses an online "Android Assets Studio" where you can design your custom Icons like:
Launcher icons
List item icons
Menu Icons
Notification icons
You can give up a try here:
http://code.google.com/p/android-ui-utils/
DroidDraw is OK, but the reality is that if you are going to write for Android you are going to want to learn how to write XML layouts from scratch. I remember that XML layouts seemed bizarre when I first started working with the Android SDK, but eventually it starts to make sense.
I read a blog post from a member of the Android team at Google explaining why XML layouts are better than GUI-based layout systems (such as the one included with the iPhone SDK). I can't find the link right now, but basically XML allows for layouts that gracefully scale across devices of radically different sizes and purposes where a GUI-based layout designer often has to be tweaked at best and redone at worst for devices of different sizes.
The official Android Plugin for Eclipse comes with a GUI Editor which supports drag'n'drop of GUI Elements. Not necessarily better than DroidDraw, but maybe you didn't know yet: http://developer.android.com/sdk/eclipse-adt.html
Related
I'm building a Java application that is some sort of Android applications (APK files) analyzer.
One of the main features that the app will offer is a "preview" of an Android layout, hence I need an API that receives an Android layout XML and a few configuration arguments such as screen resolution and theme, and returns the rendered layout as it would appear on a device running the application (graphical consistency with the real Android platform is important) along with position data of the View objects (in order to allow the user to select a view by clicking it). At the first stage, I don't expect the feature to reflect layout changes that are made programmatically, but only the View objects and resource graphics defined in the XML.
The idea I have in mind is to use the source code of a layout editor, such as ADT's editor or DroidDraw, and integrate it into my framework, but then I was wondering - maybe a better way would be to use the android API itself to render the layout for me (this is better mainly because I won't need to rewrite my code for later versions of the OS).
So my question is: does the API allows such operations? Or is there an even better way?
Any suggestions and insights are welcomed :)
does the API allows such operations?
If by "java application" you mean an app that runs on your PC, then no. There's no straightforward way to even call anything in the Android API. I'd recommend you go with the first approach of integrating some existing source code.
That said, this is not a straightforward task either. Also, if you're analyzing an APK, you'll be working with binary XML files, not the easy-to-read plain text ones that you see when developing (which assumedly are what ADT/DroidDraw use). There may be source code out there to deal with that too.
You could also consider looking at the source for Android itself, but I imagine you'd have to re-implement a bunch of rendering code, so that's no easy way out either.
At the first stage, I don't expect the feature to reflect layout changes that are made programmatically, but only the View objects and resource graphics defined in the XML.
Reflecting the layout changes made programmatically will be virtually impossible to do in a reasonable way.
This task is definitely possible, however, it's not straightforward at all. I would suggest taking a look and Android Studio's source code, more specifically there is a tool called LayoutLib.
This is the tool that the IDE's layout preview/editor uses to render layouts. You can use this to render layouts and views that you have the source code for. Unfortunately, it's not very well documented, so you have to figure out the usage from IDE's sources.
The open source Itsnat has a way to render loaded XML Android Layout files directly. it has a sample app that compares the standard (binary compiled) versions with the dynamic. My work with it shows that it does a good job reproducing all the quirks of LinearLayout/Relativelayout, etc. https://github.com/jmarranz/itsnat
I'm looking to implement a time picker like below in Android.
I've already looked at http://tolkianaa.blogspot.mx/2012/04/how-to-use-android-wheel-part-ii.html but he has multiple xml files and multiple classes seemingly so I can't see how thats going to work. (Am I missing something?)
I have android-wheel installed so this question is useless Replicating the iOS time picker in Android
The demos from android wheel don't seem to really accommodate it.
Anyway, does anyone have a better way of implementing this is android?
You should have a look at the AOSP source code, a clock app is included I think it is the default one that is shipped with ICS & JB (but I have not compiled it to verify).
Also, the official website always have some useful info, you should try to start with this widget. The illustration seems to indicate that it uses buttons instead of swiping, which is strange but even if it is the case it will be a good start to implement a swiping version of this widget.
#Lokesh's link also seems to also fit your needs.
I wanted to have a discussion on Java GUIs, right now, I'm still in school and I've done light gui development for class.(We briefly covered it.)
Plain and simple, I couldn't do anything I want, I wanted to build a nice clean layout but everything looked off and worse when you maximize it. JButton were huge when put inside a GridLayout, or they spanned the whole row, when I clearly specified the size of the button and etc. It's been one headache after another with Java gui development.
With Microsoft WPF/XAML UI development is more straightforward, it felt like HTML/CSS. Setting the width, height, margin, and padding is great, knowing where my components are going to be puts the mind at ease. And you can even design a custom Look and Feel.
I wanted to know if do you guys have any tips and resources for someone starting Java GUI development. And the one thing I don't get is launch new items with a JFrame, i.e a game.
At Launch your directed to a panel with 4 buttons.
Play Game - Takes you to a new panel to play the game.
Lobby - Takes you to a chat like interface
and etc
Should these be panels? Or more JFrames, like when a user click a button I launch the Play Game JFrame then close the menu JFrame. I really have no ideas with Java guis.
Make sure you understand and are using the appropriate layout managers. This Swing tutorial is very useful for learning how each works: http://download.oracle.com/javase/tutorial/uiswing/layout/visual.html
Also realize that you can layer layouts by putting on panel inside another. This is sometimes necessary to achieve a desired effect while keeping things simple.
For your last question, buttons can just be added to a panel that can bee adding to additional panels before a frame.
First off take a look at Mig Layout. This is a real full featured layout manager and currently is the best one available. If for some reason you can't use external dependencies then you will want to look at GridBagLayout. GridBagLayout will be powerful enough to do everything you need, but it is not as easy to use as something like Mig Layout.
In 99% of the applications you will build you will have a single JFrame and just transition the JPanels to show the different screens.
First off, one of my rules of thumb when building UI panels is to never set directly any location or size.
Then, a second rule is to never set any preferred, minimum or maximum size directly in pixels (thus will bite you when you change from one monitor to another one, with higher or lower DPI resolution). Take a look at this post on my blog, quite old but still useful today.
Thirdly, I try to avoid embedding panels into panels because it leads to components alignment problems and inconsistent component sizes.
Finally, I try to use DesignGridLayout for most of my forms, and sometimes revert to GridBagLayout if the UI layout is too complex (but a complex UI layout may also be a sign of poor UI design).
As a general comment about how to build UI applications (with any UI toolkit in general, but with Swing in particular), there are several recommendations that exist out there, but it is hard to find concrete implementations, you have to read a lot about these, and then try to find the way that works best for you.
Yes, welcome. Compared to HTML /Javascript/CSS you can get nothing like the sophistication and polish for the equivalent level of time spent learning.
(I haven't sourced all the files for you for anything here - google and start looking up).
Swing, in my experience definitely feels like I read 10 million documents, played with some demos, and spend three or four months nightly for 2-3 hours, and you have some idea of how some of the api's work, and then have no idea why some don't. Its great. You want something to work and then implement that, and proceed to f*ck up the rest of your gui.
Java swing, in my opinion, is desperately crying for an open source JQuery type plugin library that will animate your JComponents and render them in a way that you like. Its a definite second class citizen on the desktop, and especially now that CSS / HTML browser rendering sophistication has improved over the last few years.
The nimbus look and feel style is an improvement definitely in the right direction.
You could also move over to JavaFx. Good luck. Apparently its quite nice. I haven't yet had the time or patience.
If you are allowed to use thirdparty library : try JAXX as an option. The idea was to create a css type implementation, where styling elements are separated into a file that can be quickly configured and tested.
Read here for good introduction: today.java.net/pub/a/today/2006/03/30/introducing-jaxx.html
JavaCSS is found in the JAXX project. JAXX is a xml format style implementation of the swing gui interface. You write an xml document, and a css style document, and are able to bind the inputs and outputs of the GUI to your java implementation engine. The css style document allows for rapid sophisticated gui development. Using the jaxx jar engine, the xml code is converted into java code that runs as rapidly as if deployed in a .java class file.
The project has been continued by a French group of programmers and is now to be found here: http://www.nuiton.org/projects/jaxx/files
The demo is at least pretty and most things seem to work.
The latest release is JAXX 2.4.2. The latest update was May or June 2011. Whilst in French, the documentation is still comprehensible in English. Just translate.
The original ethan nicholas files of jaxx were last updated on 17-07-2009
http://sourceforge.net/projects/jaxx/
Please note: www.jaxxframework.org/wiki/Main_Page is a dead link, the site is discontinued. instead a mirror has been made and can be found at: buix.labs.libre-entreprise.org/original-jaxx/www.jaxxframework.org/wiki/Main_Page.html
This documentation is essential to understand the meaning and purpose of jaxx and its use.
If you are patient, have lots of time, and are interested, also look at the timing framework by Chet Haase, to animate your components, it is possible to create sophisticated effects. It requires learning curve and time.
Or pay to get your gui components handled by a professional third party library? (Um, the obvious answer, no-one who has spent the time and effort to learn to create a pretty gui is just gonna hand that over).
So spend three years learning and then ask for moola from others?
Another idea - I am very into exploring but it looks like it might be a nightmare to implement, despite everyone saying its so easy, get an open source webbrowser html / csss renderer embedded, and design your gui on that, using CSS / JQuery / HTML.
But it looks like you have to first compile the web browser (mozilla) from source, and then wrap that in another program (e.g. JRex) and then put the whole thing in a mini- client server like Jetty, just to have a front end implementation that you halfway like.
And that is only if the browser is actually is as compliant with the CSS2 standard and HTML4. Forget about HTML5. That is for the future.
Okay, I am grumpy today, but I don't think the gripes are completely unjustified.
The Three20 project is really nice for building iPhone apps quickly using common libraries:
https://github.com/facebook/three20
Is there anything like this for Android?
Not exactly, but working at a company with a partially three20 based iPhone app developed in parallel with the Android version, I think about 50% of what 320 does you get right out of the platform on Android, minus a little polish. For example, 320's Navigator and TextEditor are basically baked in on Android - the platform's native text editing components can stretch dynamically on their own, and task navigation and back-button history is handled automatically on Android, with URL handling baked in to the intent filter and resolution system.
You can get much of the rest of 320's functionality out of reusable libraries like ignition or GreenDroid (at least with regards to caching and images loading in lists), without the weight and lock-in a fairly monolithic framework like 320 can add to your app. There's a few bits that these solutions miss (three20's zoomable photo viewer, for instance), but there's usually acceptable hackarounds for quick usage (an Android WebView makes a pretty decent image viewer substitute, for instance).
Once upon a time there was an SO wiki page gathering a bunch of those resources, but alas, that's gone away. You can get a pretty good set by looking for popular Android projects on GitHub or Google Code, though.
See Do android developers commonly use 3rd-party UI/networking libraries like Three20 on iPhone?
How do I create a J2ME app for cellphones with a GUI similar to the menus you see in Java games? I've tried MIDlets with Netbeans but they only show you one GUI element at a time. (textbox, choice, login, etc)
And which Java IDE would you typically design these GUIs in? Netbeans or Eclipse? and is IntelliJ IDEA usable for this aswell?
Do I have to write/get a library that draws GUI controls to screen via bitmap functions .. and keeps track of the keys pressed for focus?
Try to use LWUIT - nice UI toolkit for j2me:
https://lwuit.dev.java.net/
http://lwuit.blogspot.com/
You can also use minime: http://code.google.com/p/minime/
It's an open source GUI library for j2me. miniME works on canvas level (lowest level in j2me) to draw every control so your UI will look exactly the same whatever the handset it'll be running on. Other advantage are:
- miniME uses its own event loop to manage user controlled event (botton pressed, softbar, ..), so you Application will "behave" the same whatever the handset.
- miniME support the concept of Views and stack of view, in order to make navigation between different view/screens very easy.
Here is an example: A View is what you have on the screen at a given moment (for example the main menu screen), then to go to a sub menu, you create a new view, and by calling a simple API, you push it in the stack of Views. The previous view (the main menu) is still existing, but inactive. When the sub menu view complete his work (for example, user press back, or do a selection), you can just go back to the previous view by calling a pop api.
Your question is a bit vague to give a specific aswer, but you might want to check out LWUIT or Polish, you can develop both with either Eclipse or Netbeans.
As far as designing GUIs go, neither IDE will help from a visual perspective. J2ME UI development is all done in code, beyond creating any initial graphics in a proper graphics editor you don't get to see your output until you test.
Read up on the LCDUI package documentation which explains how the UI classes work and the differences between the 'High-level' and 'low-level' APIs.
I can't comment on which IDE to use - but I do know that to create custom UI (like the ones you see in J2ME games), you have to explicitly draw the GUI controls.
Beware that you may need to customize the GUI depending on the target phones. You have to cater for different screen sizes, key pad configurations, default theme etc. This would probably mean that you need different builds for things like different screen sizes which would drive up your Java Verified certification costs (if you need it).
You may be able to find a set of nice looking UI controls that you can buy online and use (try J2ME Polish). The easy way out of course, is to use default J2ME controls :)
Links to many j2me GUI libraries: link1, link2
I know that kuix is not bad and free - watch demo.
But i prefer to make my own gui elements - this is much more flexible (but takes some time).
As for IDE - you may want to make some kind of gui-editor tool, construct interface in it, save result to some file, and read it from your app.
It's way too cumbersome to write your own GUI, especially since there are so many available these days. If you're familiar with desktop development in VB.Net and C#, you might find "J2ME GUI" easy to use. You can download it from http://www.garcer.com/. It has a similar feel and makes it easy to learn. This is the kind of GUI that I expected to come standard with MIDP2 when I started mobile development. Would have solved a lot of issues.
If you are familiar with web stuffs then you can use KUIX (kalmeo.org/home/index) framework having xml and css supports. In place of It you can use also Polish framework (www.j2mepolish.org) it's also uses the xml in easy way rather than kalmeo kuix framework.