I have a TextView that displays 13 labels by using '\n'. I chose to use only one View, since android-layouting tends to get very slow if you have more than a couple of TextViews.
I set line-spacing-multiplier to 1.3x and have the problem that between the first and the second line there's about 5 to 10 px more space than between the others. There are no special characters like Ö in the labels, everyone of them consists of capital letters only.
Is this a known bug?
Related
I need to show the price in the Android app. Design is such that text size of two digits after the decimal point is smaller than the rest of the text. I know I can achieve this with multiple TextView views but I'm wondering if anyone did it without the use of multiple views and how to do it.
TL;DR Price should be formatted like this: 5,oo USD (oo in this example represents two zeros as in zero cents with text size smaller than the number 5 which represents the number of dollars)
You can use AbsoluteSizeSpan for your TextView
SpannableStringBuilder yourText = new SpannableStringBuilder("5.00 USD");
span.setSpan(new AbsoluteSizeSpan(fontsize, true), start, end,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
yourTextView.setText(span)
You can find more information from developer webpage
You can
Check the font face that it zeros are smaller that the rest of the digit and apply it.
I have a seemingly simple task in Android, which turned out to be quite complex.
I have multiple strings, and I want each string to be centered based on a character in a specific position in that string. For example "azcde" should be centered on a character in index 1 ("z" in this case), "trxdsf" should be centered on a character in index 2 ("x" in this case), ...
Below is an example.
The problem is that characters vary in size (e.g. "i" is much thinner than "m")...
Can this be done in TextView or custom View?
I have an EditText using the image below as the background image.
The EditText is numeric only, and is limited to 6 digits long. On some devices, the digits line up perfectly in each slot, however I can not find a way to make it consistent across devices. On larger screen and high density devices, the digits do not line up, and end of being in the middle of a divider. The layout that contains the EditText is using a Weight attribute to allow it to scale correctly across devices. Can anyone suggest a method I can use to make the digits always line up in the slots of the background image - regardless of the screen size/density?
Any suggestions/examples would be GREATLY appreciated!!!
Thank you!
Use 6 different EditText views with each view containing only one digit. When user input some value in first view just change the focus to the second one to make typing the values easy.
You can also handle backspace button to taking focus back to views before.
You could use TextWatcher for listen inputing events on each EditText
This question already has answers here:
Add dots to TextView like in the receipt
(7 answers)
Closed 8 years ago.
I got a rather odd question. I'm creating an application where I display a list to the user, in the following format :
var1................... var2
var3................... var4
etc
The problem is : How can i change the number of dots based on the users screensize? Should I solve this using different layouts or dimens in /res, or is there an easier way to do it by code? I can't quiet figure this one out. Any hints, or tricks would be appreciated.
Some picture, to further demonstrate the problem, first one on the Nexus 4 preview :
And, a 3.7 FWVGA preview, clearly illustrates the problem, where the amount of dots should be decreased.
Simply position your two text boxes to extreme right and extreme left, in a RelativeLayout container by setting allignParentLeft & allighnParentRight properties. Then place a textView having lots of dots(any number 100/500),Set this textView toRightOf and toLeftOf properties, so that it is limited within the space of two inflammatory text boxes.
This should work.
You can use a GridLayout:
1st column the label text, 2nd the data.
Add android:layout_gravity="left" to the 2nd column, so the 1st column will get stretched as it has no gravity.
I am unable to align text in a table format in my dashclock extension's body. Following is the format I want (first column left aligned, rest columns right aligned):
A 2 3
BC 5 10
DEF 22 3
In the code I try aligning the following way
String.format("%-10s %10s %10s\n", val1, val2, val3);
When I log the result of the above formatting it prints in the correct and intended way in logcat. But when I deploy the app and run it as part of the dashclock application, the alignment is completely off. The alignment when displayed in dashclock extension looks like:
A 2 3
BC 5 10
DEF 22 3
I tried searching and looking into the DashClockExtension class to see if something is possible but couldn't. Also the expandedBody method in ExtensionData does not take SpannedString as argument, only String.
Any ideas as how to get the alignment right in the device?
There isn't currently a way to do this because the font used for displaying expanded body content isn't a monospace font, meaning each character has a different width. Feel free to file a feature request for representing tabular data though! http://dashclock.com/issues