Screen optimization for tablets - java

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.

Related

CodenameOne - Importing set of images in the theme

My CodenameOne app is mainly intended to be the iOS counterpart of an existing Android app. It is for older devices, in fact, as soon as possible, or in the future, a Swift app is going to replace it for OS 14>.
I need some customised icons and I have the svg code for it.
Initially I had to use the Flamingo tool, that converts svg files in Java classes.
I used it like
ScaleImageButton appButton=new ScaleImageButton(new AppIcon().scaled(doubleButtonSize,doubleButtonSize).toImage());
It is cumbersome but it does not even work on iOS.
So now I resorted to create png images for every icon in every dpi level, as it can also be done on Android.
I renamed the files so they follow the standard I think it is proposed in CodenameOne.
The possible names are:
verylow.png
low.png
medium.png
high.png
veryhigh.png
560.png
hd.png
2hd.png
4k.png
In the end it has to be used like
Image icon = theme.getImage("icon.png");
It seems that the images can be imported in the project in more than one way.
I was said to include them in the theme.
According to the CN1 developer guide I have to set the size for each.
If I import them as a whole (selecting the folder or selecting all images and hitting the "Open" button) in the theme editor a dialog appears with all wrong sizes (but they resemble a particular set of choice, although very unlikely).
They are not always the same sizes but neither they are defaulted according to the provided set of images.
I provide images as 24px, 36px, 48px, 72px, 96px, 144px, 192px, 288px, 384px for normal size icons, and also I provide double sized images for double size icons in my app (the values are not doubled as expected).
I also have to check "Square image" and "Preserve aspect ratio" options (my images are already square).
Then the strangest part is that there is a percentage, I see it is 20 for example.
The caption reads "will affect all entries". I understood that it is to scale images, that is what a developer just do not want, unless the developer has wrong sizes, but still proportioned among themselves, that cannot be the case I think.
However I do not need any scaling, the images are right as they are. I created them on purpose.
The developer guide is not enough clear to me.
So I am asking
is it right to tweak the wrong size to match the right ones, and what about the percentage?
This specific UI is a bit out of date by now and wasn't used much even when it was added. Most users opted to do desktop scaling for multi images.
The scale option is designed to scale down from a high resolution image on the desktop. You don't want/need that.
You don't need to edit the file. Just make sure to turn on the XML team mode and make sure your images use the right file names. Then once you save the images will appear in the resource file.
I suggest adding a multi-image using the standard method of add in the menu. Then replacing all the generated images with your copies and reopening the file, then saving again (the last save is important as it will override the res file).

Why my font in design viewer is blurry in Android Studio?

Why my text inside the android design viewer appears blurry. I tried changing the resolution DPI setting as well. But it didn't work for me.
Please look at my second picture, to let you know which one is I am talking about.
Try changing the scaling to 100% instead to 125%. Normally in Windows 10 default scale in 125% recommended. But using 100% will fix this.
To Find Scaling Setting:
Right Click on the desktop
Navigate to Display Setting
Dont Forget to go advanced scaling setting
And
Turn on the Fixed Scaling for the apps
Just incase sometimes
Before:
After:
How about changing device settings?
It just change the resolution of example device and it would make more clear sight from design view. It doesn't change the layout codes.
It would help the development with clear visual, but you have to test various resolutions of devices if you needed to.
Go to 'Help' tab and click on 'Edit Custom Properties'. It might ask you to generate a file if it doesn't already exist. Once this properties file was made, I wrote 'hidpi=false' (no quotations) on a new line, saved it, and restarted Android Studio.

Parts of the icon in a JOptionPane is missing on my computer regardless of screenresolution but works on other computers

So, as the title states, the icons that appears in JOptionPanes has missing parts on my computer regardless of screenresolution but works on other computers (the image shows using of lower resolution, 1366x768, but I usually have it on 1920x1080)
The other computer I tried on has 1366x768, and it works just fine!
The question is: Why is this happening (or what might be causing this) and how can I make sure this doesn't happen on other computers?
Since the text I have in for example tables appears tiny I was suspecting it might be because of ClearType is turned on, but it didn't help much to turn it off, and the other computer has that turned on too.
The GUI is set to apply the host OS's Look and Feel, but it has been working before (I develop this software from time to time so for me this just happened suddenly without knowing what might have caused it...)
Both computers I've tried this with runs Windows 8.1
I've searched a lot about this but all I could find was how to put custom icons in a JOptionPane dialog, however that is not what I want.
The picture shows the issue with the icon (to the right), while it also shows the screen resolution I tried. Maybe the appearance of the text/icons in the control panel may give a hint of the problem?
So I just did more searching on everything from ClearType to Fonts and just found a solution to my problem!
Apparantly the problem was that my screen had a very high screen resolution so Windows scaled up icons "without telling me".
The slider has the options "smaller" and "larger" (and had also "Medium" when the highest resolution was applied) (Picture #1).
One expect the "smaller" option on the slider to represent scaling of 100% or lower, but when I tick the checkbox for "Let me choose one scaling level for my all displays" (Picture #2), I can see that "Medium (125%)" is equivalent to the "smaller" option on the slider.
Of course this solved my problem with my own java program, but it also solved other problems I had before with icons in Windows UI itself (e.g. non-system icons in the notification-area had bad quality)
Picture #1 Showing the slider with the missleading options
Picture #2 Showing the radio buttons choices with scaling percentage values. Please note: Slider value of "Smaller" in picture one corresponds to "Medium (125%)" in the options of this picture.

How to design UI for android application that will compatible for all devices?

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

Graphical Layout Editor not DROPPING

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!

Categories

Resources