I have a TextView with about 10 rows. I want to have the lines more separated from each other. I can't seem to find an attribute for doing that. I tried with: android:includeFontPadding="true" but the text got all weird like stretched or something. Is there any attribute that I don't know about to do that?
Thanks in advance.
Use android:lineSpacingMultiplier="1.2" or some number greater than 1
You can use android:lineSpacingExtra="xxdp"
Related
My designer has given me the layout spec. as shown in image, so i have to give a exact 20dp gap between first TextView(Verification Code Resent) and second TextView(Please check your text message...) but their is always a default padding for TextView that increase the gap between these two TextViews, i want to know is it possible to give exact 20dp margin between these textview ,if not does my desiner need to make some changes in layout spec, i'm confused please help me..
You can use android:includeFontPadding="false" in your XML for the TextViews.
As an alternative, you can set setIncludeFontPadding (false) on the TextView in your Java code.
What I would like to achieve is an effect that looks like this with a TextView:
Basically having a background, but keeping the space between the lines. The only solution I came up with was using one TextView for each line of text, but I would prefer a cleaner one using only one multiline TextView.
Any ideas?
Use spanned text for each line. Read the Spannable API.
please refer to this answer here as it describes how to implement spacing between multiple lines in a TextView , using the following properties :
android:lineSpacingMultiplier
android:lineSpacingExtra
Hope that Helps .
Regards
What you can do is use mark tag in html to textview.
myTextView.setText(Html.fromHtml("<mark>heading highlighted</mark>"));
I'm using a Digital-7 Typeface for a pair of TextViews. The problem with the TextViews is that whenever I use the character "1" in it, the characters left of the "1" get pushed back and they lose their proper spacing. As seen here:
You can see the 9's are properly in place while the 1's get squished together. Is there any piece of code that can help me fix this or do I need a better Typeface?
As what Der Golem said, switching to a monospace Typeface fixed my issue.
Please try this property in XML, Hope it will work.
android:textScaleX="1.2"
Must be a floating point value, such as "1.2". You can change the value depending on your requirement.
I am writing text description in two lines using TextView. I am using android:gravity="center" to centrally aligned two lines & also used android:maxLines="2" & android:ellipsize="end" attributes in xml file. First line is coming properly but at left side of second line text is getting clipped. If I remove android:ellipsize="end" attribute then there is no any text cut. So i am thinking that my problem is because of ellipsize attribute. I tried a lot of experiments to solve this issue, but not succeeded. Can anybody help me to solve my issue.
Apparently, there is an incompatibility between the attributes ellipsize, maxLines and letterSpacing.
I had exactly the same issue, and setting the next line solved the issue.
android:letterSpacing="0"
Hope this helps :)
I have an edittext and I want to show 3 dots at the end when the text is longer than the edittext.
I found that there is a method setEllipsize so I've used that, but it is not working..
This is my code:
edt.setInputType(InputType.TYPE_CLASS_TEXT);
edt.setFocusable(false);
edt.setCursorVisible(false);
edt.setMaxLines(1);
edt.setHorizontallyScrolling(true);
edt.setSingleLine(true);
edt.setEllipsize(TruncateAt.END);
I've tried to add multiple parameters as you can see, but none of them are working.
Any more options I can try?
//try setting the Ems
edt.setMaxEms(5);
or
android:maxEms="5"
NOTE: you can adjust the ems size as how many chars you want to show.
Or in XML file set these for the editText
android:inputType="text"
android:maxLines="1"
SetEllipsize will work in TextView Try that
The issue here is that you're using setEllipsize with InputType = InputType.TYPE_CLASS_TEXT
For some reason these 2 don't work together :(