How can I have different xml font sizes for different Android Wear Watches?
Currently there are 280/320/360/400/480 resolution watches. I adjust my fonts programmatically after I detect the screen size with onSurfaceChanged();
Can I have different .xml for different resolution and how should I define it? It will be a lot more better solution and it will cut my code a lot.
Related
I've started using the font TT-Chocolates font in an Android app, but with font sizes < 16sp the font is being rendered uneven/inconsistently (e.g. TT-Chocolates-Regular 14sp, full resolution screenshot taken with android studio 1080x2400 Poco X3):
As you can see e.g. the "r" letters is drawn differently in two different textviews (list of elements with the exact same style and font size). In iOS, with the same size this problem does not occur.
Any thoughts? Thank you very much in advance!
We can make positioning of widgets 'responsive' by using bias/weight etc, but how do we make the font sizes responsive? By 'responsive' I mean the font size that changes according to size of device - i.e for large device the font size will be large, and for small device the font size will be small.
I tried using the library for ssp/sdp, but that didn't solve the issue.
Another suggested way is to create different font sizes in dimens.xml for different device size, and use them, but that would require calculating the different font sizes for the fonts used in the entire app.
Is there any other way?
you can use this library for font size :
implementation 'com.intuit.ssp:ssp-android:1.0.6'
Is it standard to make buttons text and other views text larger in tablet size? I make dimens.xml for different device sizes and make different text sizes for different device sizes. for examle in normal dimens file:
<dimen name="small_text_mobile">14dp</dimen>
and for large size dimens file:
<dimen name="small_text_mobile">18dp</dimen>
and use this dimens for my textViews and buttons , extra..I want to know if it is standard? or no need for that and texts of views like buttons should be in same size in different device sizes?
The unit used (dp) will convert the button and layout sizes to appropriate pixel sizes on the actual device (making them independent of actual device screen size). Therefore, on a small device it will look relatively similar to a large device. However, depending on the situation, it may be more efficient use of screen space to have different dimensions/layouts for different screen sizes. It really depends on the view being used and the level of user experience required for it. A lot of the time dp will get the job done close to what you would want. The Android documentation on supporting multiple screen sizes is excellent in explaining all the different situations and control a developer could have on their layouts.
Depending on the layout, it may be better practice to create multiple layouts to fit small and large screens in different orientations. It depends on the layout and how complex it is. If it looks unnatural on a certain device, I would recommend creating another layout (or applying some changes on the current one) to better fit all devices.
I'm working on a Android project where I need to build my layouts based on a JSON layout file. This same file is also being used on an iOS app. So there is 1 file which will render the same layout on the Android as well as on the iOS.
The JSON layout file defines its font sizes based on the default iOS font unit.
From the Android docs:
Points - 1/72 of an inch based on the physical size of the screen.
And as far as I can find, iOS font sizes are also defined as 1/72 of an inch.
So based on this info, I'd say the following should be enough:
view.setTextSize(TypedValue.COMPLEX_UNIT_PT, fontSizeInIosUnit)
This however results in the text being too large. And it also seems to differ per device (which is weird since points should always appear in the same physical size).
If you want fonts to resize properly according to screen size you should use dp/dip instead.
So try this instead:
view.setTextSize(TypedValue.COMPLEX_UNIT_DIP, fontSizeInIosUnit);
Now this might not be exacly the same but in my experience this gives the best results. If it doesn't have the proper size then figure out what size you need on Android as the base size and then go with that instead.
I know this has been answered in other questions, but nothing is working for me. I have a text view where I want the text to appear the same size in a variety of density/screen size combinations. I have tried specifying
android:textSize="30dp"
and
android:textSize="30sp"
and have also used
TextView text = (TextView) findViewById(R.id.text);
text.setTextSize(30 * (getResources().getDisplayMetrics().density));
30 is my font size *****
the text doesn't scale properly. It becomes way too small at lower densities and as screen size increases. Are there additional techniques I can use to scale my font?
create layout-large, layout-small, layout-xlarge etc.. versions of your layout xml file.
You can set the size differently in each so that the font will look right across a variety of screen sizes.
After years of constantly having everything slightly off on different devices, I recently discovered that the inches and cm measurements for dimensions are literally that.
So even on devices where 160dp isn't quite an inch, specifying 1inch will give exactly that, on everything, even if they have a custom scaled ROM.
I now specify anything I want very tight control over with these.
If you just want to have separate font sizes for separate screens, you can create dimens in your value.xml for sw600dp and sw720dp folder too and put different values there. You don't need to create separate xml layout for each, if you just need to change font sizes.