How to change text size on Android Things? - android

I developed an application on AT_v0.3 developer version, Raspberry PI 3. The application on AT_v1.0 stable version size of text and other items are bigger and they are not visible.
Also, there is no option for sizes in the settings menu on AT_v1.0. So, is there a way to fix it without re-design the layouts?

There are many changes that may have to be made to your applications between the third developer preview and the stable version. In addition to APIs, you may need to update your layouts.
In a TextView, if the font size is too large or small, you can modify the XML contents to specify a specific font size:
<TextView
android:id="#+id/text_view_id"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="14sp"
android:text="#string/hello" />
You can also use a custom theme in order to modify a number of Textview elements to adjust them all to the same extent.

Quite an assumption, however...
The key difference between Android Things Dev Preview 3 (a.k.a 0.3) and the "stable" Android Things 1.0 is that for the 1st you set up you display resolution manually via config.txt compared to the "stable" version where the system is configured via Android Things Console. You can treat the console as a black box which may downgrade a display density for the sake of more wide display coverage.
it would be sad if an Android Things developer had to "re-designing the layouts" in order to fit the configuration coming from the console.

Related

Design android layouts suitable for large text users

I'm a visually impaired developer, and I'm trying to figure out how to design good layouts for users that have the largest text enabled on their android devices. I made a good app layout and it looked fine in the designer and the emulator and it looked fine, the tested it on my device with large text on, and everything was incredibly wonky: Text was wrapping onto multiple lines and noting scaled properly. I turn off large text and everything is perfectly fine.
How do I do this? Other apps with large text are fine. What measurement should I be using and what text style/Size is the standard?
If you are looking for standard design principles supported by a strong Case to case study the Material Design Documentation is the right place to look at.
This documentation itself is created by the great minds from Google. All the thing being presented here is the do and don't.
What measurement should I be using and what text style/Size is the standard?
In general, You need to test the different system font size on different screens to make it looks good, get the font size and test it(Read font size from Settings). In my practice, use wrap_content instead of fixed height in ViewGroups(LinearLayout), and there is no standard style/Size, only the product UI design matters. In some apps like WeChat it defined custom app fontSize which will NOT be affected by the system settings, and DO the multi-devices adapt with it's own font system.

Android: Layout appears truncated on real phone

All along I've been testing on an Android 2 version ported to x86 (which runs within VirtualBox), due to problems with the emulators. My application and layout appears fine on this port.
I am now finishing my development, and am testing on my real phone, a Droid Bionic.
However, my overall application layout does not take up the full size of my screen, even when I have my dimensions set to the below. There is a black outer box that it seems to reside within and I can't enlarge this window.
If I change the dimensions of my overall layout from fill_parent to say 1000px, I can see the layout being truncated as it still sits within this unchanged window size.
Can anyone advise me how to resolve this?
Thanks
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#layout/overall_background"
android:orientation="vertical"
>
<GridView
android:id="#+id/gridView"
android:gravity="fill_horizontal"
android:stretchMode="columnWidth"
android:horizontalSpacing="0px"
android:background="#layout/grid_background"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
Edit:
I am fairly sure this is because of the screen compatibility mode you are running in because your android:targetSdkVersion in your manifest is set incorrectly. This should be set to the highest SDK version that you have tested your app with and it works on.'
Please see this link and in specific read the first few paragraphs.
There are two versions of screen compatibility mode with slightly
different behaviors: Version 1 (Android 1.6 - 3.1)
The system draws the application's UI in a "postage stamp" window.
That is, the system draws the application's layout the same as it
would on a normal size handset (emulating a 320dp x 480dp screen),
with a black border that fills the remaining area of the screen.
To disable this version of screen compatibility mode, you simply need
to set android:minSdkVersion or android:targetSdkVersion to "4" or
higher, or set android:resizeable to "true".
Edit: Please see the documentation on how you should be setting the target SDK attribute
These lines in particular are of interest:
To maintain your application along with each Android release, you
should increase the value of this attribute to match the latest API
level, then thoroughly test your application on the corresponding
platform version.
Given that your ran into this issue tells me your target sdk is set to 3 or lower. So Android 1.5 or lower. This means that anyone running your app on a phone with something newer then Android 1.5 is going to be running in compatibility mode. This leads to decreased performance and incompatible default graphics. I.E. the graphics will not look like what everything else on the phone looks like because of the compatibility mode.
Currently something like 95% of all Android are running a newer version then 1.5.
What you need to do is up your tarket SDK to 4,5,6,7 ... etc one at a time and fully test the App until you get to the current SDK release of 15. When you release the target SDK should be 15 to ensure it runs well on all OS versions.

Android phone and Tablet problem

I know this is not a technical related question.But i do not have any idea.I am going to develop a project which should be supported in both phone and tablet.Is it possible having one project working for both tablet and phone ?
Yes. The only thing you need to keep in mind where you keep your graphics. Because it will cause different problems if you do not treat and handle them depending on the screen size. Only thing matters is the android version. If you deploy your app in any phone or a tablet where the version is newer or equal to the target version it works. But of course you cant take a call or some other mobile functionality from a tablet if its not supporting that features.
You can use drawable-hdpi,drawable-mdpi and drawable-ldpi for the graphics(images which use in project) and also use layout with multiple screen by custom layout like layout-480x320 , layout-600x1024 etc. in layout you can custom screen xml file.

android: UI on real device problem

I wrote simple aplication for android. It works great in emulator. But when I installed it on real device (htc wildfire) then the interface became ugly. Except that it works good. TextViews look fine but the buttons, sprinners and list items look bad. Button corners seem wretched. All the lists (list view and list preference have no delimeter(line) between rows! When I scroll a bit the delimeter appears). Why?
The buttons probably become stretched because you're not using 9 patch images. Here's a good tutorial on 9 patch images http://developer.android.com/guide/developing/tools/draw9patch.html
Regarding the list view, you might want to set this field inside listview in your xml file
android:cacheColorHint="#00000000". That might do the trick.
Have you specified a targetSdkVersion in the uses-sdk tag in your manifest? If you haven't, Android will assume your app does not know about newer platform versions with different screen sizes/densities and run your app with compatibility scaling.
You should always set targetSdkVersion to the newest version of Android that you are targeting. This helps let Android know what compatibility behaviors to use for your app if things changed in newer versions. targetSdkVersion can be greater than minSdkVersion, meaning your app knows how to take newer platform features into account while remaining compatible with a minimum version.
Most likely, screen density is different on the device. Instead of specifying sizes in pixels (px), use sp for font size and dp for everything else. This way they will scale properly.

Best practices for targetting a wide range of devices and screen sizes

As you know android today is many versions many constructors, many screen sizes,...
it's quite difficult for developers today to write programs that targets a big part of devices.
What would be THE developer must-know practices for this ?
tips for fluid layouts.
"standards" for developing on any android version.
...
Any other ideas ?
For Layouts
First, you should start off by reading the official Supporting Multiple Screens Best Practices. There are a lot of good tips there, as well as a general idea on what you need to be looking for in terms of compatibility.
One thing I've found to be very helpful, which seems quite obvious, is to actually test your layout in various sized emulators. How does your layout look when expanded to 1024x768 (even though no device will have such a res)? How about when it's super tiny and square? Seeing how your layout stretches/contracts will help you tweak it to better fit all screens.
layout_weight
In layouts, android:layout_weight is a powerful, but under-documented attribute. Using it, you can create layouts where components are sized in percentages to each other.
For example:
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText android:layout_weight="80"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button android:layout_weight="20"
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content />
</LinearLayout>
In this layout, the <EditText/> will take up 80% of the available width, while the <Button/> will take up 20% of the available width. Obviously, this should be used carefully so that all items can still be usable even if they are small.
<include />
Another helpful layout practice is to bundle up common bits of your layout into separate files and include them using <include layout="#layout/smaller_section" />. That way, you can shuffle around other parts of the layout (say, for landscape), without having to keep entire parallel versions of the layout.
The only things I've found so far:
Develop to the lowest SDK version you can. I target 2.2, but only use APIs from 1.6 and so far (touch wood) that's worked out well. You can still support things like backup and move app to SD card thanks to these being driven by the Manifest.
For really small screens you will probably need a separate layout. Using the emulator I've found that just reducing the size of the graphics doesn't make the layout usable - you need to re-arrange and strip out some elements.
Sometimes you need a separate layout for portrait versus landscape mode - but often the portrait works fine in landscape.
It'll be interesting to see what other have to say - particularly around providing multiple drawable resources for different densities. I've not been able to isolate why it's sometimes required to use -hdpi and sometimes not to get good results on a hdpi screen.
I tend to use a mobile stylesheet that is only included when the app is accessed from a mobile device. This stylesheet generally applies a min-width (depending on user and device requirements), and fills the content up to 100% of the screen width.
Other suggestions:
mobile-specific landing page, taken
up entirely by a menu and a search
box
evaluate what content is actually important to a mobile user and focus on that
No dead ends - even if a search returns zero results, make it easy to continue on (new search, page suggestions)
geolocation if applicable (ie a
google map showing store locations
nearby)
test on a variety of devices if possible (ie
blackberry's native browser tends
to have difficulty with jquery)
I agree with Johnny, use a mobile stylesheet. For example:
<link rel="stylesheet" href="screen.css" media="screen"/>
<link rel="stylesheet" href="handheld.css" media="handheld"/>
However whatever you do at the bottom of the page allow the user to interchange between the two. For example many 'mobile' sites include a link at the bottom to view the 'full' site. This way the user makes the concious decision over the capabilities of their device.

Categories

Resources