The layout editor itself is working fine, but it doesn't want DROP where I want it to drop.
It's only dropped in the very top left corner, and gravity doesn't change anything. If I drag it elsewhere, it just doesn't work.
It's the same anywhere, whether it's a different xml or just a new xml.
Is this an eclipse problem or a Java problem?
Thanks, and Happy New Year!
Do you come from an XCode or Visual Studio background? If so, yes, the "graphical layout editor" for Android is weird, as it depends chiefly on relative positioning of elements, unless you user AbsoluteLayout controls, which give you pixel-by-pixel positioning power.
This looks to be a good overview of the different kinds of layouts available in Android... the thing you have to remember about Eclipse and its ilk is that they assume you want to use certain layouts (Linear appears to be the default), to make it easier for you to create layouts that scale appropriately to size, irregardless of pixel density or resolution.
http://www.sitepoint.com/know-your-layouts-in-android/
Good luck!
Related
I can't scale and move components in IntelliJ with its GridLayout. The problem is when I move/scale components they don't move to the exact place.
Picture (But I think you'd better check the vid out)
I uploaded a video on youtube
Here it is https://www.youtube.com/watch?time_continue=9&v=X6CF7TJ7GJg (sorry for a non-english speech)
You should learn how Java Swing Layouts work. Most layout managers do not allow you to place the components where you want (there is so called Null-layout, but it's not supported by IntelliJ IDEA).
You normally use splits, spacers and constraints to define where the components will appear and how they will resize when the form is resized.
I am developing android applications from last four months, but still i am not able to design UI which will support for maximum screens. What should be my ideal layout and drawable structure and what is the good way should i follow to achieve it. Please help me.
Thanks in advance.
Well the best way to do that will be:
the same icon with different sizes and put them in order in the(these are order from smaller sizes to bigger sizes):
mdpi
ldpi
hdpi
xhdpi
Th OS will automatically get you the best icon to fit the screen.
Obviously if you want to run your apps in tablets as well it will be extremely hard to achieve a layout that can be compatible with thousands of devices available on the market.
For that you can create different layout folders and create several of them for different screen sizes.
For more info you should definitely see this dev page:
http://developer.android.com/guide/practices/screens_support.html
Hope this helps
Use RelativeLayout or LinearLayout with weights. So that you get same view on most on screens. You can use one copy of images with good resolution in drawable folder that can adjust on most screens or different sizes images in different drawable folders but its increase your app size. But its always good practise to create layout depend on different sizes and some layouts based on height and width.
I'll quote the top answer of this thread which is pretty much equal to your question.
That may not be possible. However you can look at these links and
learn how to provide different images(pixels and density), layouts and
further on. It may not be possible to make a userinterface on a low
level density screen the same way as a high density screen and then
you can target different layouts to different phones e.g.
Providing Resources
Application Resources
You should also have a look at this: Best practice supporting multiple screens.
Although it is possible you should focus on a few main densities/screen sizes which you will support. Test these and make sure they work as you want them to do. It will be very much work to support all varieties and may not pay off because only few phones use specific sizes.
Best way to implement Fragment
And also use import any icon with the following steps
Right click on Project
select ->new -> other..
Then choose Android Icon Set
Launcher Icons, Icon Name
so on...
You can follow this tutorial http://www.vogella.com/tutorials/AndroidFragments/article.html
I have optimized my app for just about all Android phones. The way my app is set up, I have a 16dp padding on the left and right side of it and a 65dp padding on top and bottom (see screenshot below). On a phone it looks beautiful.
But on a tablet, it looks terrible. 65dp on a phone is a whole lot different that 65dp on a tablet. On a tablet, the black border around the question runs off the side of the scroll background and stuff is on the roll at the top and bottom of the scroll background.
What are my options to fix this? Is there a percentage/weight option for padding? I think that would solve it completely but there is nothing like that that I know of.
You can create multiple resource files tailored for different display sizes. Android will automatically choose the correct resource file for you. Using this technique, you can specify padding values for any screen size, or even completely unique layouts, to be automatically selected for you by Android.
Please refer to Designing for Multiple Screens.
Using multiple dimension resource files would make the task of changing the padding based on screen size very simple. See More Resource Types.
I've designed my program in both null layout and the free design layout, however, when I compiler my program and run it with the null layout the window gets resized (Despite my original size, and specifying the default size, minimum, maximum etc) and the buttons are not visible anymore. However, when I compile and run my program in free design layout, the size is perfect and it works great, but my components get screwed up when I perform all sorts of operations (example : making a component visible, setting the text, etc). Is there any fix to this? I believe this is a netbeans bug but I can't tell. Please help this is a disaster. I'm using Netbeans 7.0.1
Is there any fix to this?
Yes, use a layout manager. Using a null layout is almost never the way to go.
If you need to rearrange the components or change labels at runtime, the 'free design' is probably not the way to go. Its not designed for this, and it really has nothing to do with netbeans. You will need to understand how to use the appropriate layout managers to make it do what you want.
In addition to the standard layout managers, you might also want to look at Mig Layout.
IIRC, netbeans also offers an XY layout for absolute positioning. This is only a bit better than null layout though, because your UI will look bad once it hits another system, but if you don't care about that then that might be the right answer for you.
I'm looking for a Java UI designer allowing me to drag and drop controls directly to the design surface in a floating mode (without the hassle of north, south etc that comes with SWT). Is there any such tool?
Also, I'm only interested in tools offering a trial version.
EDIT: I'm only interested in solutions allowing me to drag/drop items regardless of panels margin, LayoutManager stuff etc. The position should preferably be just relative to the window margin.
Thanks in advance
You can use NetBeans to design your GUI. Instead of messing with Layout Managers, just use the "Absolute" layout. It will put the UI Components exactly where you drop them, pixel for pixel.
Eclipse has a free visual editor called VEP. See http://www.eclipse.org/vep/
Instantiations has a very nice set of tools with a trial version:
http://instantiations.com
Note that for any visual designer, you should know how layout managers work to use them properly (and make sure your UI expands/contracts/adapts to font/locale properly). If you just use absolute placement, things can get cropped, for example.
See http://developer.java.sun.com/developer/onlineTraining/GUI/AWTLayoutMgr/ for my article on layout management to get a feel for how to use things like North, South. It only covers the original five Java layout managers, but describes why you need them and how you can nest them.
I recommend JFormDesigner, which has support for "Free Design". From
http://www.jformdesigner.com/doc/help/layouts/grouplayout.html:
The goal of the group layout manager
is to make it easy to create
professional cross platform layouts.
It is designed for GUI builders, such
as JFormDesigner, to use the "Free
Design" paradigm. You can lay out your
forms by simply placing components
where you want them. Visual guidelines
suggest optimal spacing, alignment and
resizing of components.
It has a trial version and is very easy to use.
Netbeans has a drag and drop module called Matisse: http://www.netbeans.org/kb/articles/matisse.html