Adapt app to all screen size - Design, Prototyping, UI, Graphics

Hi, I'm developing a material design calculator but I have a problem: How could I do to adapt buttons to alla screen size? For example on mi Xperia S buttons are too small! If you want screenshot or the xml code tell me it. I'm sorry for my bad english I'm only 14 XD

Hi,
You need to use the size in DP instead of PX and use max/min size attribute on your XML file

Start using dp (density independent pixels), they are designed to scale a graphic to "real-life size" for example 48dp is a little bigger than the size of our fingers and is the recommended size for buttons in order to be easily touchable.
If you need more info about density independent pixels read from Android Developer's page "Supporting Different Densities" (I'm new here and I can't post URLs, just google it).

At first you need to read "Support multiple screens" article on android developer website.
For my opinion the best way is to use wrap_content match_parent instead of pixels.

Hi,
Since you mentioned you're making a calculator app, while using "dp" for button dimensions, I also suggest you look into using "weights".
These can evenly space out your buttons in a layout.
To use weights in Android, your content must be wrapped in a LinearLayout.

Related

Registry entry for changing scroll bar size.

Can someone point me to the info regarding the registry entry for making the scroll bars thinner. I have looked every where and searched for scroll bars.. cant find it.
got it.
had to sneak over to the q forum.
here it is.
1. Making the scrollbars smaller (Vert. and Horz.)
This hack allows 4 icons on a row in the start menu instead of 3 and allows more to be viewed on the screen in IE:
• Go to: HKey_LOCAL_MACHINE\SYSTEM\GWE\
• Adjust the following values
cyHScr : Horizontal Scrollbars
Height in pixels (default is 6, set it to 3)
cxVScr : Vertical Scrollbars
Width in pixels (default is 6, set it to 3)
• Soft-reset
Its mostly nicer for web browsing.
also this asks for you to create them, they are allready created.
Bump for a good change that I felt was missing from the new roms. Thought others would appreciate it.

[CAB][22-Feb-2010] Smaller HTC Menus

Intro:
HTC's menu enhancement is very finger friendly but it also limits the number of items you can see at one time and you have to scroll down to get to the rest, which can be annoying at times.
This modification will make the items smaller so more items can fit (see screenshots).
Thanks to cybermaus for his original work on this here.
Requirements: WVGA device and you must already have large HTCMenus enhancement.
For VGA: mkucuksari made cabs here and etoy has a thread here. Thanks to them both.
UPDATE 28/01/2010
I've updated Small Menus for the latest HTC Menus version. There are no huge changes, but it does include a faster animation ratio and new grey default highlight.
I've also added matching Small Menus for Manila (Sense) - see screenshot below.
UPDATE 08/07/2009
A new version of HTC's Menu Enhancement has shown up in cooked ROMs (specifically I noticed it in Dutty's WM6.5 R4). HTC made a few changes like removing the up/down arrows completely and putting a scrollbar instead. I've updated the modifications for the new version. I haven't made a Medium size for v1.1 because the new version is already that size by default.
You must install the correct modification for your version of HTC Menus.
How to tell which version of HTC Menus you have:
New version 1.1 has a scrollbar instead of up/down arrows and the highlight is a little different. Pretty easy to spot:
HTC Menus 1.0:
HTC Menus 1.1:
For HTC Menus 1.0
There are 3 different sizes: Medium, Small and Extra small.
See the screenshot below for size comparison. The original menu size is enough to display 7 items at once. With Medium that's up to 9, Small displays 11 and Extra small 13.
Choose the size that's most comfortable for your fingers. If you're not sure which one to install: I'd recommend Small, as its probably the best fit for most.
Download for HTC Menus 1.0:
Medium
Small
ExtraSmall
For HTC Menus 1.1
There are 2 different sizes: Small and Extra Small.
See the screenshot below for size comparison. The original menu size is enough to display 9 items at once. With Small that's up to 12 and Extra Small displays 14.
Download for HTC Menus 1.1:
Small
ExtraSmall
For HTC Menus 1.1.Updated
There are 2 different sizes: Small and Extra Small.
Download for HTC Menus 1.1.Updated:
Small
ExtraSmall
For Manila Menus
The size can be adjusted from registry:
HKEY_CURRENT_USER\Software\HTC\Manila\Menus.Height
HKEY_CURRENT_USER\Software\HTC\Manila\Menus.FontSize
- Default small height is 60, and default small font is 22.
Download for Manila Menus:
for Manila 2.1
for Manila 2.5
for Manila 2.5.20xx
for Manila 2.5 VGA
===================
c00l, always wanted to have that, thanks!
thanks alot I like it
very good ,I want it long time
THX...VEry coool
This is really A MUST HAVE. Congratulations.
Thanks. Very useful indeed.
Great! Will try right away!!
Great! Works like a charm on Dutty v3...
Very thoughtful, thanks a lot, works perfectly on Davide V5
Is it possible to change green selection color to any other?
FileFixer said:
Is it possible to change green selection color to any other?
Click to expand...
Click to collapse
Yes. I can make a different colored skin. Just name the color (would be good if you can provide the exact color hex value).
Also, if anyone wants to make a custom skin for the menus the bitmaps are "HTCMenus.bmp" and "HTCMenus_mask.bmp" located in \Windows. I attached them below for convenience.
Thank you... I will be edit this pictures in Photoshop to make my favorite color.
Regards.
http://forum.xda-developers.com/member.php?u=1375656
thank you...waiting for this
must have, you make it possible, thanks
bookmarked1
Great!
I like it very much!tks
hey Co0kieMonster,
this is excellent, great work!
Question (request really), anyway you could make another one of these that's a median between the this one and the stock one (aka, slightly bigger than the one you made, but smaller than the original). I agree that stock is too big, but I'm 6'4" (2m) so I have big hands/fingers and yours is just a tad small for me. Totally understand if you can't or don't feel like.
Thanks!
Svegetto, see if this one is a better fit.
9 items are displayed at once so it's right between the original large menus (7 items) and the small menus (11 items).
Two more sizes are also possible: with 8 or 10 items, so I can tweak it a bit more in case this one's too small or large.
Co0kieMonster said:
Svegetto, see if this one is a better fit.
9 items are displayed at once so it's right between the original large menus (7 items) and the small menus (11 items).
Two more sizes are also possible: with 8 or 10 items, so I can tweak it a bit more in case this one's too small or large.
Click to expand...
Click to collapse
This is perfect. Much thanks!!
Hi Co0kieMonster,
i'm totally happy with this mod, makes my life alot easier .... but
my fingers could easily use an even smaller size ... would it be possible to have 13 items?
making it user-adjustable would of course rock too

Size of Form

Hello,
i have an application, programmed in C#. I wanna that the size of the gui will automatically adapt to the size of the phone on which the application get used.
How can I do this?
In the Paint() event of the form examine its ClientSize property. This is the size of the client (White) area of the screen. It is itself a Size object with Height and Width integer properties, this.ClientSize.Width and this.ClientSize.Height
Use these values to position/resize your objects on the screen, by changing their Size and Location (Left and Top) properties, so that they fit in this area.
This event occurs before the Paint() event of the child objects, so they will be repositioned/resized before they themselves are drawn.
To be clever, reposition and resize screen objects, scaled to the screen size at run time, not values hardcoded at development time.
This technique can also detect a change of orientation, the values of Height and Width change over! If you want to be smart, handle this as well, and your app should be starting look pretty damned professional. A bit of work and it should look good on all screen sizes. Test them out against the SDK's emulator images for a range of device screen sizes.
The following code example positions the label in the correct place. Hey Diddle Diddle, slap bang in the middle!
Code:
private void Form1_Paint(object sender, PaintEventArgs e)
{
label1.Left = (this.ClientSize.Width - label1.Size.Width) / 2;
label1.Top = (this.ClientSize.Height - label1.Size.Height) / 2;
label1.Text = this.ClientSize.Width.ToString() + " x " + this.ClientSize.Height.ToString();
}
do you have to do this with every object you put on it? Seems like a lot of code. (also im doing this in VB so far..)
I'm afraid so. But it's worth the effort. Also it will run on all screen sizes, see image, and also the oddball ones they haven't thought of yet!
Change 'this.' to 'me.' and omit the C# end of line character ';' and it's now in VB.
Does your form property AutoScaleMode is set to AutoScaleMode.Dpi?
For controls set the anchor property (default is top|left) also to right (and/or bottom if needed). That will automatically 'stretch' the controls.
Advanced:
Now, if you really want to support different resolutions it will take much more work:
As already mentioned you have to rearrange the controls on orientation changes. Take a look at Developing Orientation and dpi Aware Applications for the .NET Compact Framework!
And finally you have to provide images in different resolutions.
Adapt to New Screen Orientations and Resolutions
Of course you have to decide if this is really needed for your app as this will take much more time.

[win32] API - New Sense interface Look 'n Feel V1.6.4 (01/28/11)

I have created a win32 API for C++ that mimics HTC's Sense UI Look 'n Feel... More informations on my website: charlie-soft.com
DOCUMENTATION : http://charlie-soft.com/Software/Manila_SDK/html/
This SDK is designed for speed: .NET applications are usually very slow to load and not fluid. I use some tricks to improve speed, like drawing only area having changes, scrolling without backbuffer or creating textures for text (GDI text drawing was slower…).
What’s in the box:
PNG resources for VGA/WVGA. They can be easily modified. SDK will resize automatically the resources if your device has a smaller (or higher) resolution!
Design your app for VGA, the SDK will adjust the layout for other resolutions!
Full Finger Control.
Source files (.cpp and .h) of library.
Source files of example.
Class:
MyEditControl: Edit box with different width. Easy get and set text. SIP detection: scroll Edit area.
MyItem: Button (3 types), checkboxes and switch (TripleState!). Event on click, visibility and state can be changed/get easily.
MyPanel : This element is not visible but is used to bring together elements. This element can have a title and dotted separator between each element.
ChildSection : Contains a subsection which is displayed with a sliding effect.
MyLabel: Print text with different font and color.
MyPictureBox: To print image (png, jpg, bmp, gif…)
MySelector: Like the HTML select. Scroll screen if list is out of screen (see video below).
Section: A section is a panel which can be scrolled up/down. It contains the different elements.
MessageBoxSense: Four type of messagebox: info, Ok/Cancel, Abort/Retry and Yes/No.
MySlider: A simple slider of any size... The min and max values can be changed easily, as the cursor position.
Change log
V1.6.4
Added the possibility of multilines in edit control
V1.6.3
Added possibility to add picture to slider of ChildSection...[bug solved]
Explorer bug solved
V1.6.2
Added an event when user click on screen...
V1.6.1
Memory usage improved
V1.6
Loading of image is now safe (use video memory by default but if problems use device memory)
File Explorer
Icons
Speed and memory improvement
V1.5
just add possibility to change color of text for hover and selected...
Minor bug changes:
items out of screen no longer try to redraw
text of items recompute their size when changing
background color is correctly changed
The SDK is now multi thread safe!
Add the possibility to right clicks (long press)
Add the possibility to hook windows message (WM_ACTIVATE for example)
Add the possibility to have a bottom bar.
Add the possibility to have a background image (landscape and portrait).
If the app is allready started, close the new instance and show the previous one.
MySelector can be scrolled if the list is too long.
Text is now printed with alpha transparency.
Compatible with any character (hebrew, vietnamese...).
MyPictureBox can now be stretched.
Memory usage reduced.
V1.4
Minor bugs fixed
Add the possibility to show MessageBox without a main application.
V1.3
Background can be transparent ! (see this app for demo)
Native drawing (DirectDraw was too slow in landscape)
Slider can have a force feedback (see this app for demo)
V1.2
MySlider added
drawing process rewrited: less redraw->less computation->less CPU utilization -> battery consumption reduced
Loading optimisation
The layout is now independent of screen resolution!
top taskbar is occassionally cleared [fixed]
White screen, touching the panel brings it back [fixed]
landscape items position incorrect [fixed]
V1.1
landscape compatible
Abort/Retry added to MessageBoxSense
TripleState Checkboxes and OnOffItems added
FAQ
is QVGA resolution supported?
Yes, SDK will find the correct resolution and select the appropriate resource resolution. The SDK will delete the other resources...
have you planned to extend MessageBox types to Abort/Retry?
Yes, to create one:
MessageBoxSense::show(L"Hello",L"Try again ?", MESSAGE_ABORTRETRY);
is this landscape compatible?
Yes but having refresh rate issue. Seems to be a DirectDraw problem (S2U2 was subject to the same issue...)
If someone know how to solve this problem, send me a message !
Back button too slow.
You can change the speed anim using this function: changeSpeed(double nbMilisecond)
why aren't you including some TripleState Checkboxes and OnOffItems ?
Both are now included:
new MyItem(1,5,15,ITEM_IS_CHECKBOX,ITEM_THIRD_STATE,L"My third checkbox (Third state)");
Other apps
Wake on Wan is a new app which use this SDK. Sources are available!
Quick shutdown is a software which use this SDK too. It can turn off, restart or set the phone in sleep mode. Sources are also available!
"
Sense SDK win32 C++
For informations about SDK (installation, use compile...), see here: http://charlie-soft.com/Software/Manila_SDK/html/
Good work ! thanks for sharing hope devs will use it.
Hello my friend !
Great work !
( C'était exactement ce que je cherchais en c++ pour mes MFC smart device !!! )
Great Work, Thx for the source!!
Really great work!
but I have two questions:
- is QVGA resolution supported?
- have you planned to extend MessageBox types to Abort/Retry?
thank you
regards
NIce work
Altough i don't really know what todo with it... i instalt the example.cab and it was really smooth!
Only one thing if i go to other controls and i want to change the value then the onscreen keyboard should show up right? But it doesn't.... So i slide my qwerty keyboard open, and in landscape i get an error message: DDERR_SURFACELOST(back buffer)
I dont know what it means... is this landscape compatible?
Good job man !
Nice works !
I just have a feedback, I find too slow the animation when you click on the "back" button, is there is a way to speed it up ? (or disable simply the animation)
SDK Manila
Hello all !
I will try to answer all your questions. So :
- is QVGA resolution supported?
No but easy to implement... Just resize resources to correct resolution. I will post resources shortly.
- have you planned to extend MessageBox types to Abort/Retry?
If it's something wanted, I will do it.
- is this landscape compatible?
No, not yet. But will be in next release!
-Back button too slow.
I will add a method to set the speed of animation... in the next release
-Bug with hardware keyboard
The onscreen keyboard don't show up and I don't know why... I will look around for a fix.
If a developer wants to translate .NET applications into C++, feel free to post I will try to help you!
There is still lot of work, but I will try to do this quickly!
petititi said:
- have you planned to extend MessageBox types to Abort/Retry?
If it's something wanted, I will do it.
Click to expand...
Click to collapse
thank you for quick reply. I need this extension for my app "htc menu loader" (link in signature) to migrate from .net to c++
again, really great work. You are making something that HTC should have done months ago.
Great project !
I don't know if you notice but I disabled the bottom taskbar... Do you think that I should add the possibility to enabled it? I saw that your application needed one...
I hope you will find my SDK easy to use !
Hey, this looks awesome.
Question though: I'm just shy of clueless when it comes to making an actual working app. Is there any place I can go to read/learn the coding I will need to actually use this?
Application win32 c++
You can use the example application included into the SDK to learn basic stuff or you can download this application: WakeOnWan. It’s based on my SDK (here are the sources).
You need some basic knowledge about Object-oriented programming and C language. I try to explain how to use the SDK in the example using comments or on my webpage.
I will also post a short tuto in second post...
Very, very nice! The demo runs very smoothly on my stock Touch Pro 2.
petititi said:
You can use the example application included into the SDK to learn basic stuff or you can download this application: WakeOnWan. It’s based on my SDK (here are the sources).
You need some basic knowledge about Object-oriented programming and C language. I try to explain how to use the SDK in the example using comments or on my webpage.
I will also post a short tuto in second post...
Click to expand...
Click to collapse
Awesome thanks!
What's sad, is when I was young, I used to be able to code in C. Made my first video game when I was 6 on a Commodore 64 (ok i dated myself here) Now, can't remember very much
C++ ? It's just like riding a bike!
Hatefly said:
Awesome thanks!
What's sad, is when I was young, I used to be able to code in C. Made my first video game when I was 6 on a Commodore 64 (ok i dated myself here) Now, can't remember very much
Click to expand...
Click to collapse
I'm sure you can!
It's just like riding a bike - you never really forget how. And we are here to help you to refresh your memory.
petititi said:
I'm sure you can!
It's just like riding a bike - you never really forget how. And we are here to help you to refresh your memory.
Click to expand...
Click to collapse
Sweet thanks! Just downloaded an ebook on c programing.
Sounds (and looks) great, although there are still to many glitches (like not working in landscape etc.) which are preventing me from using this package.
But I have one question, why aren't you (all) including some TripleState Checkboxes and OnOffItems ?
I need them often but you cant find such controls online - not to speak of sense.
TripleState Checkboxes ?
Hello,
the TripleState Checkboxes is a simple feature I can add. To be sure, TripleState Checkboxes will looks like:
And tripleState On/Off:
I will include them in the next release... Be patient, the next release is coming soon and adds support for portrait and fixes a few bugs...

How to get smooth graphics (no jaggies)?

Hi
I built a simple clock app yesterday. It was surprisingly easy. One question I have though is how to make my images smooth (without jaggies). I drew my clock face and hands in photoshop. At first I did them at 300x300 pixels and the jaggies were so obnoxious I threw those images away. Then I did everything at 1000 x 1000 pixels and resized down to 300 when I was finished. This was much better, but still not as smooth as the clock in Jelly Bean. I notice that most of the graphics and fonts I see in Android are all very smooth. I've been testing the app on a Galaxy Nexus.
What is the secret to creating/displaying nice smooth images?
Thanks, Derek
vector graphic is the keyword with fix sized effects (photoshop, ie. inner shadow is always 1px, above 256px use 2px)... yeah, the simple bitmap resizing won't give pro result for you
Heh Yeah, I've had this problem and it was a ***** to solve. Mainly because the answer is distributed over a dozen different posts on half a dozen different forums.
Anyway, the answer depends mainly on if you're using imageviews/buttons or something or if you're drawing directly to a/your own canvas. But the way to solve it can be applied to both. It basically involves using BitmapFactory.Options and configuring it correctly:
Code:
private BitmapFactory.Options ops;
ops = new BitmapFactory.Options();
ops.inPurgeable = true; //means the system can recycle and reclaim the memory used by the bmp when the system has low memory
ops.inDensity = 0; //load the bitmap without scaling it to the screen density
ops.inDither = false; //don't dither (you only want dithering when you're working/converting between bitmaps/canvasses with different color depths (16bit to 8 bit etc)
ops.inScaled = false; //no scaling, related to some other settings in ops
ops.inPreferredConfig = Bitmap.Config.ARGB_8888; //load the bmp into a 32bit argb bitmap
ops.inJustDecodeBounds = false; //if true, you're just looking at the underlying bmp data, eg to see the height/width without loading the bmp into memory
//then load your bitmap like so:
Bitmap yourbitmap = BitmapFactory.decodeResource(getResources(), R.drawable.yourprettybmp, ops);
Now you can use the bitmap to draw onto all kinds of surfaces or load it into widgets.
Be warned, this is a non-mutable bitmap. If you want to change it's data (like you want to draw on it by making it the backing bmp of a canvas) you'll have to get a copy of the BMPFactory.decodeResouce bit by adding
Code:
.copy(Config.ARGB_8888, true);
to it.
For resizing the bmp, you can also do the following (which returns a mutable bmp, so you won't need the copy bit above):
Code:
yourresizedbmp = Bitmap.createScaledBitmap(yourbmp, width, height, true);
Of course, you can combine all this in one step (where "res" is a reference to getResources()):
Code:
yourresizedbmp = Bitmap.createScaledBitmap(BitmapFactory.decodeResource(res, bgIDInt, ops), width, height, true);
One more thing to ensure quick drawing, lower memory usage etc is to define the window type of your activity to match the colour depth of your bitmaps. You can do that by adding the following to the onCreate of your activity:
Code:
getWindow().setFormat(PixelFormat.RGBA_8888);
And if you're also drawing to a surface canvas in a thread, you also set that:
Code:
mSurfaceHolder.setFormat(PixelFormat.RGBA_8888);
Anyway, the most important thing is the "ops" section. Hope you get it sorted!
PS: clean, minimal graphics can often be more easily gotten by just drawing things yourself on a canvas (extend the View object and override it's onDraw()). Just use a correctly setup and antialiased Paint to draw circles, lines and text on it and use the result.
Bitmaps are not generally used for graphics. Try to use PNG images, Google does so too.
I might be wrong, but from the OP it seems like you're using the same image size for all resolutions, use the Android Dpi Calculator to easily get the right dimensions for each screen resolution (and put the resized images respectively in /res/drawable-xhdi, hdpi, mdpi, ldpi...)
If you didn't do so, then it's definitely the problem as mdpi is the default behaviour of /res/drawable, so it will be awfully resized on your xhdpi Galaxy Nexus.
dealy663 said:
Hi
I built a simple clock app yesterday. It was surprisingly easy. One question I have though is how to make my images smooth (without jaggies). I drew my clock face and hands in photoshop. At first I did them at 300x300 pixels and the jaggies were so obnoxious I threw those images away. Then I did everything at 1000 x 1000 pixels and resized down to 300 when I was finished. This was much better, but still not as smooth as the clock in Jelly Bean. I notice that most of the graphics and fonts I see in Android are all very smooth. I've been testing the app on a Galaxy Nexus.
What is the secret to creating/displaying nice smooth images?
Thanks, Derek
Click to expand...
Click to collapse
Not sure if you've fixed this already but it's really easy. No code is required to remove jaggies, regardless of resolution. Assuming you're using Photoshop, choose save for web and devices, then select PNG-24 (not jpg or PNG-8) with transparency enabled. Initial resolutions of 200x200, 300x300 etc. are all fine; there's no need to create it at 1000x1000 and scale down if you need something smaller. Your graphics will look great.
One more tip - clock widgets fill a certain number of "squares" on the home screen grid, so just make sure that you determine the right number of dp pixels to cover the size you want (e.g., 2x2 or 2x4, or 3x3) and then specify it in xml. See the Android site for widget sizing.

Categories

Resources