Need approach for screen development in android - android

I need expertise advice/approach for starting screen development in android.
I got a couple of screens from my customer and i need to develop them.
I went through lot of tutorials and understood about supporting multiple resolutions and sizes all that is fine, but i want to understand basic things like how to properly place the UI elements. Should we need to use any tools like photoshop for measuring units like top bottom right left etc and place the UI element in xml or just by approxiamtion we will place the UI element.
For example consider this screen https://d13yacurqjgara.cloudfront.net/users/137442/screenshots/1234960/attachments/166804/Login-screen.png.
for ex How you will place the user name and password edit texts. I mean how much of top left bottom margins will be used. is that just approximation or need to be measured using tools like photoshop.
Say i used photoshop and got the values in pixes if i convert them to dp and use those values in layout will they support for other screen sizes??
are there any tools which can take the screen iamge which i posted above as an input and generate the android layout from it.

You don't need Photoshop to measure the units. The Android SDK has several layouts with their accompanying properties and options that will allow you to pretty much achieve any UI implementation. imho there are not tools that will 'take a screen image and generate the android layout from it'.

Related

Is there a "readable content guide" on Android?

Now that it's 2022 and Android tablets (and their cousins, foldables) are getting more prevalent, I got my interest ramped up in building a better tablet version of one of my apps. Coming from iOS, there is a useful layout feature that one can use when designing tablet UIs called "readable content guide". Apple describes it as follows:
This layout guide defines an area that can easily be read without forcing users to move their head to track the lines. The readable content area follows the following rules:
The readable content guide never extends beyond the view’s layout margin guide.
The readable content guide is vertically centered inside the layout margin guide.
The readable content guide’s width is equal to or less than the readable width defined for the current dynamic text size.
A picture is worth a thousand words. To the right is some text aligned to the readable content guide (the left version just spans the width of the main view):
Looks great when reading long-form content, doesn't it? Thus, my question:
is there a standardized version (that is, without me having to code one myself) of a feature similar to this on Android?
Now that version 12L is out, I thought it would incorporate something like this, especially with Google promoting Jetpack Compose (and other new UI extensions) as a faster and easier way to build UIs.
If you know what a comfortable width is you can use android:maxWidth="yourWidth" to limit the width of your textview to what you want

Design android screen mixing text and graphics, better approach?

I will like to develop an application in Android 4 that shows some gauges, text, images, etc.
It will display information read from sensors connected to IOIO board (hardware):
- temperature gauges (linear and angular)
- horizontal horizon (10Dof IMu)
- speed (vertical gauge)
- altitud (vertical gauge)
- etc...
Basically like a Garmin G1000 but the horizontal horizon will be displayed in a square (not all the screen). For example this image: Garmin G1000 image
The screen will contain text and graphics. Some graphic may change high frequently (horizontal horizon, speed, etc), but other no (temperatures, fuel qty, etc).
I was wondering what is the best approach to do it: draw all the screen with canvas, or put text with Textview and graphics with transparent bitmaps, or other options.
I will like if someone could say me what he think about the best approach to design it and to organize the visual components.
Thanks in advance.
With android, your design space is quit limited. So for something like that i would suggest nesting some layouts. You'd set one for the background and others for what ever function you wanna do. I also suggest planning what you wanna display and what layout is best optimized for the function.Eg:
Use a relative layout to set the landscape background
Use the Liner layout for the ruler functions on the sides
Use grid layouts for maps maybe
Use Split action tabs for the options at the bottom
Use menus for calibration settings
Use Relative layouts for all the funny gauges moving about and textboxes and stuff.
Then from there it's a matter of making everything work.
Here are some links on layouts:
Link 1 Link 2

Android UI based on top and left property

I was working with Android UI in Eclipse and found it to be bit hectic. Designing layout using layout managers is bit time consuming. So i was wondering whether it is possible to specify the position of the UI elements based on (x,y) system i.e top and left property which is widely used in Visual Studio IDE for VB,C# etc ?
Positioning element based on top and left property would provide much flexibility.
How would that be flexible? Yes, doing layout correctly takes time, but if you do it right, it will scale properly to any screen size. If you're using X/Y coordinates, you will be hardcoding to a specific screen size, which is an especially bad idea on Android (as there are a multitude of screen sizes available).
If you need x, y positioning, you can use a FrameLayout with foregroundGravity set to top|left, and use layout_marginLeft for the x value, and layout_marginTop for the y value.
You can use AbsoluteLayout and suppress deprecation warnings in your code, but think of how will it look on different screen sizes?
I would advise to use RelativeLayout in your case.
As far as I know, there is no built-in layout that is based on (x, y) coordinates. You might be able to find 3rd party libraries that can do this for you. However, I'm skeptical that they will provide satisfactory results. Remember that Android is deployed on a wide variety of devices which include a range of different screen sizes and resolutions. This means that you can make the UI look pretty on one device using specific coordinates but it won't look very good on other devices.
Personally, I edit my UI layouts directly in the XML files. I find that this provides me better control than using the Eclipse UI editor. You still have to learn how the layout managers themselves work.
Android tries to ensure that your layout components are arranged nicely so that they:
don't overlap with each other
don't go off the screen space
look similar on different screen sizes
etc
It gives you nice XML Attributes to help you arrange your layout. I would recommend you use RelativeLayout for this application, because it allows you to put your layout components in positions RELATIVE to each other.
Some XML attributes you can specify are given here: Android Reference, RelativeLayout.LayoutParams

Android Design versus iPhone Design, Relative versus Absolute

I have a client who wants me to build an Android version for their existing iPhone app. The design of the iPhone doesn't use any native iPhone elements. It's basically some sort of grid with containing images, buttons, text, etc. Of course it was easy to make the iPhone app because of the fixed pixels widths/heights. The basic grid that defines a screen is loaded via a XIB file, and I load the custom buttons in the right containers in the grid by specifying the exact coordinates.
Then comes Android...
Our client wants to target 3 specific tablets (1024x600). They have given us designs for a ~600x980 portrait version of the app. It is not recommended to use AbsoluteLayout in Android. What is the easiest way to make sure that I can scale it on different devices but that it will look like the given design on the 3 target tablets.
One idea I had (which I'm not sure about whether I can implement it) was:
Get screen width in pixels and height
Based on width/height ratio of the design, pad with bars on top/bottom or left/right
Still do an AbsoluteLayout based on this information
I'd rather not do it this way because it sounds involved and counter to the Android way of doing things. Another issue that is created by scaling is the following. There is a bar of buttons that have a lines separating them. These lines are 4 pixels wide. Obviously, when you start scaling, this is going to mess this up completely. I can't seem to find much information about this s
You probably want to start here:
http://developer.android.com/guide/practices/screens_support.html
But quick points are probably
Do not use an absolute layout. Your life will become terrible
Handle sizes in density independent pixels so they will scale properly on different devices
Use ninepatch images so that when images stretch they will stretch in the proper regions maintaining your 2px borders ect.
Take advantage of the different resource folders for images at different densities (drawable-mdpi vs drawable-hdpi) and layouts at different sizes (layout-small vs layout-large). The latter will allow you to have separate layouts for your tablet devices.
Best of luck :-)

Android animating image pieces and device compatibility

I am creating an application which on one view has an image of an elephant. this elephant needs to animate various parts of his body such as eyes, trunk, spraying water, and also the background/horizon movements. I have briefly tried positioning each element(eye, trunk, etc) in a RelativeLayout using margins and relative positions so that the picture looks correct.
When i change the screen size via eclipse layout editor everything gets out of place. I read that using RelativeLayout with margins and relative positions will be the best alternative to AbsoluteLayout, but i can't seem to get each piece in the right spot while keeping some compatibility of devices.
What is the best way of positioning pieces of the image to complete a full image which will also allow me to animate/translate/rotate/etc each piece and support a large variety of devices?
I thought that maybe using OpenGL or Canvas might be the way this is done properly, but i don't see how these would resolve the problems i've mentioned.
I have created the iOS version of this application and it was extremely easy to set this up. I don't quite understand how applications line up sprites to make a scene which is compatible among a large variety of screen sizes/densities.
You will have to scale the elements of your big picture to fit the High , medium and low screen densities .
To do this you will have to resize each set of elements and copy them into separate drawable folders :
/res
drawable-hdpi
drawable-ldpi
drawable-mdpi
also you can create a dedicated layout for each screen category if needed but first try just to scale the images and copy them into the folders and launch your application.
A good link to see also : http://developer.android.com/guide/practices/screens_support.html
P.S: make sure to use dp not pix as measurement unit on your layouts , also the use of absolutelayout is not a good choice it's deprecated.

Categories

Resources