11

I'm developing quite a few homescreen widgets and currently I have to install them on my emulator or my phone in order to preview the layout.

Is it possible to preview the layout in Eclipse? When I open the XML of my layout in the preview mode, it displays it as it it were an activity and therefore the scaling is entirely wrong.

Pedantic
  • 5,032
  • 2
  • 24
  • 37
Mridang Agarwalla
  • 43,201
  • 71
  • 221
  • 382

3 Answers3

9

You can use jimu as a plugin into Eclipse to achieve it. Jimu is a drag & drop style App creation tool for Android. That's the most suitable tool to allow you achieve what you have in mind to get WYSIWYG, as it will enable you to have live previews of Android layouts. You have also the option to use it with Eclipse, or with Android Studio or any other editor of your choice.

To avoid the need to compile-install-run, jimu Mirror gives you live previews of your app that update as you code.

enter image description here

As you can image, the most positive fact about Jimu is that it speeds up Apps development times.

Jimu - what you see is what you get

Alternatively, you can use IntelliJ IDEA. IntelliJ IDEA also allows you UI layouts preview.

enter image description here

Thus allowing you achieve WYSIWYG. And equally IntelliJ IDEA gives you the option to integrate it with Eclipse. Of course, alternatively you may decide to simply completely to move to Intellij IDEA. It is available in a commercial edition as well as in a free open source community edition.

enter image description here

IntelliJ IDEA UI designer allows you to build application UI by dragging widgets from its side palette. In version 13 you can simultaneously preview the UI you’re creating on multiple devices, by just selecting Preview All Screen Sizes from the device drop-down. Preview displays all changes made through the UI designer or XML editor in real time.

enter image description here

Such tools for GUI implementation from Jimu and IntelliJ IDEA remembers a little bit Qt Designer, which is available also for Android. In fact, any approach that properly works, allowing interactive Android UI quick development, is a greatly welcome valuable tool for developers that should be well used to improve productivity.

Community
  • 1
  • 1
Avanz
  • 7,466
  • 23
  • 54
  • Does Jimu allow you to preview a homescreen widget in the right size? – FD_ Apr 29 '14 at 08:33
  • @FD_ - it does allow preview a widget in the right size indeed. just use Jimu as a plugin to Eclipse and that allows you to preview a layout, just like CDT allows you to program C++ in Eclipse. haven't you never heard about it or tried before? well... something crazy, but also good about computing, specially about mobile computing... is that things move extremely fast and new tools and trends are rising all the time. – Avanz Apr 29 '14 at 08:47
  • @Avanz, apart from being easy to use by having drag-and-drop; this doesn't let me preview the widget layouts, does it? It works fine for activities but doesn't explicitly let preview appwidgets. I'll give this a shot to see. – Mridang Agarwalla Apr 29 '14 at 08:54
  • @MridangAgarwalla - yes it allows you preview the widget layouts. jimu Mirror gives you live previews of your app that update as you code - http://www.appbrain.com/app/mirror%3A-live-layout-previews/com.jimulabs.mirror . – Avanz Apr 29 '14 at 09:01
  • @MridangAgarwalla - IntelliJ IDEA also allows you UI layouts preview http://blog.jetbrains.com/idea/2011/10/new-in-intellij-idea-11-preview-of-android-ui-layouts – Avanz Apr 29 '14 at 09:32
  • Just want to clarify that [AppWidget](https://developer.android.com/guide/topics/appwidgets/index.html) is quite different compared to general app development. One of them is the fixed layout size, which is quite cumbersome since you can't preview it in layout editor (at least true in Eclipse, since I've experienced it) – Andrew T. May 01 '14 at 15:11
  • @AndrewT. - IntelliJ IDEA UI designer allows you to build application UI by dragging widgets from its side palette. In version 13 you can simultaneously preview the UI you’re creating on multiple devices, by just selecting Preview All Screen Sizes from the device drop-down. http://blog.jetbrains.com/idea/2013/12/intellij-idea-13-brings-a-full-bag-of-goodies-to-android-developers – Avanz May 05 '14 at 01:27
0

At the top of the view in Eclipse switch to the Holo Panel theme. If you need your own theme attributes then create tour own theme override that parent's to this. Then you could choose that in the editor.

Simon
  • 10,932
  • 50
  • 49
0

it displays it as it it were an activity and therefore the scaling is entirely wrong.

If it displays as an Activity, then create a dummy Activity that mimics the home screen. Then use a theme, or use an include tag to include the layout from your widget into the cell(s) of that larger dummy home screen.

This solution isn't ideal, but it should be able to give you a better approximation (if what you're looking for is just to tweak the layout of your widget).

Stephan Branczyk
  • 9,363
  • 2
  • 33
  • 49