I have a problem with layout being cropped when displaying on screens with curved edges. I have a simple layout with some edittexts and a button. The edittexts are cut off on the left side and it only happens on Samsung Edge devices. Can someone know how to deal with these curved edges screen, because adding larger margins seems like a workaround and on flat screens wouldn't look well .Couldn't find anything useful about the issue,.
Thanks in advance.
I believe there are 2 possible solutions to your problem.
WindowInsets: They describe a set of insets for window content. They make it easier to display your UI while taking in to account the system UI and factors of your display.
Guideline: If you are using a ConstraintLayout as your base layout, using guidelines as your horizontal bounds make it easier to design a responsive UI. For example you could set a horizontal guideline at 0.05 percent and another at 0.95 percent, which would keep you content away from the edges, while also keeping your UI responsive at various screen sizes and densities.
Related
Many app's, including the swipe left Google Now screen have a colored background and very large margins to compensate for the small amount of data on tablets, particularly in landscape.
Are there any standard dp dimensions for these margins on particular devices?
I'm aware of the activity_horizontal_margin but it's far bigger than that.
There are Design Guidelines available for Android Application.
Baseline grids : All components align to an 8dp square baseline grid for mobile, tablet, and desktop. Iconography in toolbars align to a 4dp square baseline grid
List : A two-column, left-aligned list with a 56dp floating action button.
Detail view : A detail card with a 56dp floating action button.
For e.g.
Above link contains all information regarding your question.
Better go through it.
Thanks.
I am trying to create an android app where I have a single relatively big button in the middle (the light blue in the picture) and it is surrounded by other smaller buttons as shown in the picture (some of small buttons might be visible or invisible based on some criteria).
I started with the RelativLayout setting the big on in the center and making the rest placed in relation to it, but it is a miss and the central button get shifted and doesn't stay in the center. I tried placing them in FrameLayout and used margin to adjust their locations, that worked the best however, the spacing changes on different screen resolutions.
So what is the best way to achieve such layout that will look consistent on any device?
Android's Percent Support Library allows you to use proportions to lay out your views, which may allow you to get closer to your goal.
http://developer.android.com/tools/support-library/features.html#percent
I am migrating from Android to iOS (Swift). In Android UI elements are scaled up or down (height and width using "dp", layout_weight e.t.c) according to device size.
However I find this VERY difficult to achieve with Auto Layout's constraints, I want the elements in my UI to scale according to device size.
For example, in the shared image below, asides the compression of images to fit the screen width, every UI element has the same size, only looks like UI elements have been duplicated with same specs on all screens
This might help others in their migration from Android to Swift
(I only pinned the width of the 2 ugly ImageViews below)
P.S: This is what I'm trying to replicate guys, this view to fit properly on all screens. Sorry for the blur, I'm not in charge of this project
There's a zen to the AutoLayout. Let me see if I can give you some direction.
You'll want to test every UI on the smallest simulator available (iPhone 4S). This will let you know if you need to adjust your elements' minimum size.
Now for a top-to-bottom review of your UI posted:
"Profile" looks fine
To make the top-left and top-right boxes resize with screen size, you'll
want to give a constraint to the superview on left and right sides respectively. Then you'll want to make a horizontal constraint between the two (to maintain a space between them. Then you'll want to set them to equal widths. You can also set aspect ratio constraints for each one.
Your forms look fine. I can give more guidance here if the look you're after doesn't match the image you posted.
For the views below the form, you'll probably want to follow #2 above.
As for the height issue, set a constraint from your bottom view to the superview's bottom. There might be crowding, interface builder might yell. Chances are, you'll need to set the horizontal spacing constraints from = to >=.
I have a design that I need to follow in my app. In it there are several buttons, images and textviews placed all over the screen (some are aligned to the left, some to the right, some are centered etc). What I need to do is make all those elements appear EXACTLY as they are in the design image. The problem is, if I try to do this using dp, it can be wider or narrower than the design image specifies, and it depends on the properties of the screen. (I've had an app where I did it all in dp, and on my high-res phone it works perfectly, but on my friend's older phone it cuts away the edges of the activity)
My question is, what elements do I use for this? I've heard of using weight in Linear Layouts, but how to make items different width and height and position them all across the screen how I see fit? How to make sure it looks exactly the same on all screen sizes?
Thanks in advance! :)
Edit:
The point is, I need the buttons to be just as they are on the screen (this will be a listview element, I'm trying to make an xml for it). The distance, proportion, everything, it needs to scale to the width of the screen and be this size and distribution. And, I'm not just looking for a solution to THIS particular problem, I want to learn how to do it in general...
You don't. For very large and very small screens, you use separate layouts that scale the sizes, completely drop parts of the UI, or lays it out in a different manner. It's absolutely silly to think you can fit all the stuff on a 10 inch tablet and a 3.5 inch phone. If your designer expects that, tell him he's an idiot and he needs to get back to work.
For a more general answer on the best way of laying things out- it depends on the effect you're trying to get. You should never use pixel counts, and dp should only be used for small things- a bit of padding between 2 fields. Most things should be done via layout, either by using a linear layout and getting things in rows/columns, or a RelativeLayout and describing how to layout views relative to their siblings. But even with these tools you will not be able to fit on all screens and look good.
I made a UI with many UI elements such as button and it takes a lot of space vertically.
The UI fits on my phone (it's 16:9 like many), but on phones with a different screen ratio, the buttons on the bottom are cut off of the screen.
I'm using a linear layout. How do I fix this?
Instead of trying to create a UI that is like an image and displays at a fixed aspect ratio, start thinking about designing for resizing. To accomplish this, you need to make decisions about what in your layout must be fixed in size, and what can acceptably resize or scroll.
Importantly (and this is my own stylistic opinion), you should avoid layouts that clutter the screen or fill it with detail. Your layout sounds like an input form of some sort; one solution in your case might be to let the controls in the upper part of the menu scroll, while anchoring the buttons at the bottom of the screen, or to just place the whole layout in a scrolling view. But ask yourself: will this be user friendly? I suspect this solution will look dense and (on really small, resistive displays like that of the LG Vortex) become hard to interact with.
Try to separate your UI into easy to comprehend little "nuggets", omit unnecessary information, and if you must, split the UI into different activities or fragments.