Is there a "readable content guide" on Android? - 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

Related

Why mostly values are multiples of 8 in Android xml?

Why most of the time if we have to create a margin, padding or anything inside xml we use multiples of 8 or 4?
I was trying to know what is the possible reason for this? Why isn't it an odd number mostly ?
Spacing methods and layout grids define structure, hierarchy, and rhythm in your design. When correctly used, they reduce decision-making and help establish a rational approach to type scales, positioning, sizing, and spacing.
Base Unit
The base unit defines what every measurement will be a multiple of.
This keeps designs consistent, improves communication with developers, and reduces the number of decisions a designer has to make.
The most recommended base unit is 8px because it makes scaling for a wide variety of devices easy and consistent.
This is because most screen sizes are divisible by 8 and because 8 is itself an easily divisible number (8/2=4, 8/4=2).
On other hand, as Material Design (is a design system – backed by open-source code – that helps teams build high-quality digital experiences.) explained,
All components align to an 8dp square baseline grid for mobile, tablet, and desktop.
Icons, type, and some elements within components can align to a 4dp grid.
Refer to these articles for more details,
Everything you need to know as a UI designer about spacing & layout grids
8pt Material Design GUI Templates

Need approach for screen development in 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'.

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

dynamically configuring views for a ViewPager widget?

First let me say that I'm very new to android development (although I have a good understanding of the basics of java), and I am building a magazine reader app for a campus publication I work for.
I want to display each article using a ViewPager widget. I'm going to build a java program which enables the magazine editor to post articles in .txt format onto a server, along with images associated with each, and have the android app periodically download these articles to a local folder.
I'm a little confused about how to construct the views for each ViewPager from the text files. Somehow my logic needs to determine the size of the screen running the app, in order to know how many words can fit on each screen.
Is this right, or am I fundamentally misunderstanding ViewPager somehow? If so, how might I structure the program to configure the views dynamically based on the txt + images given to it?
From what I understand, each page will contain as much of the article as possible, and when the user selects the article they will be able to see the entire thing. Something like this, but so it fills up the entire screen?
If this is the case, you have two options here:
Just ellipsize the textview so that it ends with a "..." at the end. Probably the preferred solution.
Resize the TextView to fit all your text (Auto Scale TextView Text to Fit within Bounds).
EDIT:
Here's a different interpretation of your question.
From what I understand, you're trying to have something like an eBook reader with an undefined number of pages; kind of what Flipboard does:
Basically, once all the text fills in the entire area you want to have it continue to the next page.
The easiest way to do this, if you do not need native performance, would be to just use a WebView, split the text across several columns, and have only one column be visible at a time.
However, it is certainly possible to calculate how tall the entire text would be and then split it up accordingly; i.e. Pagination in Android TextView
It seems similar questions have been asked and addressed: Splitting a TextView into multiple TextViews relative to screen height (see the accepted answer).

Need to create spreadsheet like control, what should I extend ListView or GridView?

I am an experienced developer, but I'm inexperienced on the Android platform. So I am seeking some advice from developers with more experience with Android.
I am building a Honeycomb application using Fragments. One of the fragments calls for a vertically scroll-able read-only "HTML table-like" view with dynamically loaded data. Similar to a spreadsheet, I should have clickable headers which I can implement server-side requests to filter/sort the data.
I am pretty sure this Control doesn't exist yet, am I right? Do I have to build it?
Assuming I have to build it, which existing widget should I extend? ListView, Table, GridView?
I assume I would have one widget for the header, and then wrap the body of the table in a scrollable layout to handle scrolling while keeping the header visible. I am concerned that I might not be able to guarantee that the headers line up with the columns.
Thanks in advance,
Tim
Android layouts are pretty basic - there are not any shipped layouts that will really do what you are looking for automatically, but you could probably do what you want with a heavily controlled gridView. Android is also pretty bad about controlling multiple elements to fit within the screen size, as it's goal is to support multiple screen sizes and densities.
From what I understand your desire to be, I think the best solution is to create a nx2 grid view dynamically, and control the width of the view based on the device size. You would have n number of headers on the top, and you could fill the lower half of the grid with your textViews, or whatever data you wanted. The hard part would be keeping the widths of the grid elements under control and on the screen. In addition, you will probably find that you can only fit a small number of header items on the screen because of the phone's small size, so you may discover a better layout to fit your needs.

Categories

Resources