How to set dot in vertically center of textview example (. Set .) , I want both dots in vertically center of set text. i have been tried with gravity center but didnt get any success, You can refer attached image where dot show after just now with very light color, i want same , so please suggest how to achieve this
Use a bullet character, \u00b7
There is no way you can do this in the way you are trying to do it.
Remember, fullstop may look as just a dot, but in reality, there is empty space above the dot. From bitmap perspective, it is as tall as any other character.
You may, however, try below 2 approaches:
Use different character instead of fullstop. e.g. "\u00B7". It looks like ·set·
Change the font size of just . (not possible in simple textview, AFAIK. Possible in rich text edit boxes.)
Set margin from top in negative(like -10dp).
Related
I am trying to find a library or a simple trick to fix the width of each letter in an EditText so that the dashed lines on the background match exactly the number in the EditText. You can see the photo for the desired effect.
Using various widget i.e. Edittext in a row with the text style to underline will helps to get these type of design else i don't think there is any hard and fast rule or tricks.
There is no simple way of doing this, especially not when aligning to a given background, because many factors such as display size and density can change the relative positioning of the EditText. You could perhaps work around this limitation by drawing the white lines under each digit yourself, using a custom font or underlining and separating the digits with a space. See this question for a more detailed explanation on the limitations and possibile solutions concerning letter spacing.
I only know that, font monospace will be useful. Other fonts set different widths to each character.
My aim is to get something like this:
aligned points image
https://i.stack.imgur.com/2tI2N.png
but currently I am only able to get !
This https://i.stack.imgur.com/trMCv.jpg
i.e.: in a single textview
Heading
Point 1
Point 2
Point 3
Sub point 1
Sub point 2
And so on...
I tried adding spaces but if the line is longer than the width of the screen it then starts from the mowt left part
Eg:
Heading
Text--------------------------This is
Point 1
Text-------this is point 2
Here pont 1 is longer than width so continued from extreme left and not just below of starting of point 1
As shown in the uploaded image
It is not looking good,
And I have no idea where to begin with to achive that kind of alignment.
I think spannable text may be used.
But I dont know how to align it like that.
Will AlignmentSpan work?
If yes how to use it to achieve that alignment?
Any direction or example will be very helpful.
You would most likely want to have an IndentedTextView or something along those lines that adds padding or margins to the side to get the proper formatting your looking for.
create a textview for each paragraph and make sure you set the same layout margin on each textview. Create a text resource for each text, if you want to add bullet points do this:
<string name="text_with_bullet">\u2022 Text with a point</string>
maybe use String.format, you can see Formatter for more details.
I tried both to align a few TextView objects and they gave me the same results. What exactly is the difference between 'baseline' and 'bottom' ?
To visualize the difference, I usually imagine two textboxes in Word or Photoshop.
alignBottom lines up the bottom of the textboxes. (The blue outline)
Text could be uneven, but the boxes they're in would line up on the bottom.
alignBaseline aligns the actual text within the box. This can help ensure that the texts line up on the bottom, regardless of font size or textbox size. (The green line)
What is a Baseline?
Baseline is a typography term that refers to the invisible line text is written on.
(As referenced in What is the baseline in RelativeLayout?)
Warning
If you're not careful, using alignBaseline could make your layout look like this:
Details: Watch That Baseline Alignment
I don't know if you're still looking for the answer, but I decided to at least put this out there since this was one of the first results.
I'm developing android application using Titanium 3.X. I need to add an image and a label (name) in a way that label is next to the image in same row and both should be right aligned. The problem is label text which represent a name is dynamic. So I can't set right property for the image view. I need to do this in a way which compatible with different devices (Screen sizes). I have given my font size as 11dp.
right property for image can be calculated by some algorithm which accepts font size, device screen width etc. But I couldn't identify it. Can anyone suggest me a way to resolve this ?
In this situation, I would add a view to wrap the image and label. I would set the view's layout to horizontal. I would then right align the view.
You should use a layout that will do the computations for you.
The RelativeLayout is quite useful in such situations. When you construction it in XML there are attributes like alignParentRight or layout_toRightOf that should prove useful. Don't forget to set the width of the TextView as wrap_content.
I have an app where I am trying to add text shadow to a TextView. The problem is: the shadow is always very thin. I'd like it to be thicker.
I am trying to generate "memes", as some of you might know from the "fun sites" on the internet. My goal is something like this font:
http://d24w6bsrhbeh9d.cloudfront.net/photo/4324188_460s.jpg
I am using the same exact font, Impact. The problem is, when I add a black border shadow, the shadow is not visible enough and it's not wide enough. It's barely barely noticeable.
I am defining a FrameLayout, with the picture on the bottom and two text fields, one on the top and one on the bottom. The shadow is barely visible for both of them.
I have been using the parameters, shadowDy, shadowDx, etc. I know the shadowRadius is the parameter that actually defines the border size, but I have been experimenting both with values above 1 and below 1, and I can't seem to get any good results. There are minimal changes in size and shadow density, but nothing useful.
I have considered another option, which is a last resort, which is drawing the text twice, a bigger black font in the BG and align the character spacing so that the black text becomes the shadow of the white text on the front.
Thank you in advance !
You won't be able to accomplish that effect with the basic TextView shadows. I'd look at adding a stroke instead:
https://stackoverflow.com/a/2151964/321697
http://developer.android.com/reference/android/graphics/Paint.Style.html