I am using a Custom font in my app(Gotham_book.ttf), and when I use it in a pre-Lollipop devices it includes a padding bottom that it's not showed in lollipop devices.
I tried to use the property android:includeFontPadding="false" but it didn't give me results. What is happening? Maybe a wrong font file?
Thank you!
I have discovered the question by searching for "Lollipop padding", but my problem is a bit different from OP's: instead of having extra padding on old devices my font (a custom image font, used via Callygraphy) mysteriously gained padding on some new versions (with difference between even "minor" Android versions!). I discovered, that in my case these issues have been caused by the font not having proper values in certain tables, so I had to fix it up myself in Fontforge font editor. See detailed explanations here: http://designwithfontforge.com/en-US/Line_Spacing.html.
TL;DR: do set contents of OS/2 font table properly. And if nothing else works, you can set corresponding values to zeroes (e.g. no padding) and/or manually adjust positions of font glyphs (Fontforge allows these kinds of operations en masse).
Related
I'm having have some issues with using a custom font ( Typeface ) in Android.
What happens is that when rendering text in a TextView, the last line is often partially cut off vertically (the lower parts of letters like g, j, y, etc missing) , even if there's PLENTY of space below the text. I assume this is because there's something wrong with the custom font file ( an OTF file) that I'm using. This does only happen when using this custom font. If I use Android standard fonts, not setting my custom typeface, everything works fine.
Question: What are the requirements for font files for Android, so that they work correctly. (Please don't post workarounds for the issue, I'm aware of those. )
Both OTF & TTF fonts Will work fine in android,You have to take care of textsize and paddings arround it.
I am trying to have a custom EditText based on the background that i am using for. The Background image has some spaces between the entry areas so i need to have some space between the characters(kerning) to fit them right in. So for example after every character the user enters, i need to put 4 whitespace after that.
I couldn't find any solution for this on the net so far, some people suggested TextWatcher, but i couldn't manage to make it work as i want it too.
Can someone help me about it?
Thanks
I have you considered using a custom font? Some font types are made to stretch out or shrink or have empty spaces. With so many different fonts available online, you can definitely find something. You can also make your own with a software. It might be time consuming if you start the lettering from scratch. I'm not 100% sure if it'll fit exactly to your background, but it's idea that you can consider.
If it doesn't fit, I supposed you can always customized the background to fix your font too. Here's the code for those who might want to use custom fonts in their app too.
Typeface myfont = Typeface.createFromAsset(getAssets(),
"fonts/Blocks2.ttf");
myeditText.setTypeface(myfont);
The font is in the asset folder under another folder called fonts.
This question is related to How to change letter spacing in a Textview?
As shown at this issue: android format edittext to display spaces after every 4 characters a solution might be to insert spaces with Java code...
You need to use TextWatcher to achieve visual purpose spaces.
And use any simply split string by space logic to join it back or loop
through the entire string per character wise and eliminate (char) 32
from the string
As far as i know actual character spacing is not possible, though i'd love to use that myself as well.
Another option might be to use a custom font with the character spacing included.
I am trying to implement the minimumfontsize property in android. This is common to the ios sdk. Since it is not presently available in android I was wondering if anyone can help me with a similar implementation in android?
To be more specific, I am trying to implement this property for the TextViewUI in android.Hence I basically need to implement it for this widget.
These are the ios specs of this feature:
"When drawing text that might not fit within the bounding rectangle of the label, you can use this property to prevent the receiver from reducing the font size to the point where it is no longer legible.
The default value for this property is 0.0. If you enable font adjustment for the label, you should always increase this value. This property is effective only when the numberOfLines property is set to 1."
Without knowing what you intend to do with the code, there isn't much help to be had. The closest thing to what you describe in android is setting device independent pixels (android:textSize="30dp"), which ensure that however big (or small) the text looks on your handset, it will look pretty much just like that on all other handsets, at least those of the same size/density. See R.attr and Supporting Multiple Screens
Is it possible to have the followings in android font styling.
Leading (the space vertically between lines of text - name comes from the physical piece of lead that used to be used in mechanical printing process to separate lines of text).
Tracking (the horizontal space between each character).
If you have any ideas please share with me.
You can change leading by calling TextView's method setLineSpacing() or changing corresponding XML attributes of TextView in layout (android:lineSpacingExtra or android:lineSpacingMultiplier).
As answered here:
AFAIK, you cannot adjust kerning in TextView. You may be able to adjust kerning if you draw the text on the Canvas yourself using the 2D graphics APIs.
Update: since API 21 there is an option to set kerning/tracking/letter spacing. You can call method setLetterSpacing() or set it in XML with attribute letterSpacing.
For Tracking, check out this answer. It works fine for me.
I'm developing an Android app targeting Android 2.3 (API9).
I want to resize the height of a simple EditText but when I set android:layout_height="10pt" the border of the EditText becomes dislocated.
The problem is shown here
I tried layout_height, height, textsize.. pt, px, sp... but the same problem.
I haven't tried the application on real device yet.
What layout contains the EdiText? You should never use exact pixel sizes when configuring items in Android, since your layout needs to work properly at many different screen sizes and densities. (See supporting multiple screens for details).
If you really want a specific size, us dp for density independent pixels. It should work to set the layout_height="10dp" However, that won't increase the size of the text within the EditText. You need to use textSize for that. You are probably better off setting textSize and setting the layout_height="wrap_content".
See this similar question about the extra line. It looks like setting a background color might fix that.
I have been having the same sort of problem (and it's a real pain). With some experimentation I have found that if you use "dp" and apply this rule of thumb, it should work for EditText fields.
textSize x 3= layout_height
I say rule of thumb because the minimum height before the field "breaks" again is about 29dp. So, for example if you have textSize="10dp", then layout_height="30dp", or textSize="12dp", then layout_height="36dp". You can have smaller textSizes, but it becomes illegible lower than 9dp. I found this works well in relative_layouts with default fonts. Good luck!