How to align points and sub points in a textview? - android

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.

Related

Larger padding only in last line of a text view

I wonder how i can set the padding of only the last text view line larger then the padding of the other lines. (Like it is done in WhatsApp chat with the time in the chat bubble). Maybe this picture elaborates:
The padding should follow the red lines. Adding more vertical padding to move down the clock is not the solution i am looking for.
In android you can't apply padding for specific line into TextView
You have 2 solution :
1- Merge both text in one text Html
2- Align both textview end and bottom and add 8 spaces in the end of message
example worked for me

set fullstop (.) center_vertical with textview android

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).

What's the difference between alignBaseline and alignBottom in Android?

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.

in a paragraph how to find the each line's first and last word programmatically in android textview

I want to find the line's first and last word of a paragraph.
sample :
My country is Turkey.I love my country very much.
There are four season in my country in a year. Each
one has 3 month. That's the place where every one
live *in*.
In such a paragraph, I want the words that is in Bold.This paragraph is in textview
and the code must take care of the width of textview.If width changes, first and last words also changes, and algorithm must find them.
If you help, I'll be glad.
I'm not sure how android handles the actual placement of text with resizes and all that. I really doubt that it adds in tab carriages and newlines to the text to display them, but if it does, you could use regex to find that. Or regex with the line anchors. Take a look at this, see if it helps:
http://www.regular-expressions.info/anchors.html

Android clip upper part of text in TextView

I need to have two TextViews displaying same number, first of which should display upper half and second lower half in order to animate those parts differently. (See images below, there's an example with '8' digit).
http://img403.imageshack.us/img403/2461/bottomtop.png
While clipping bottom is perfectly simple (setting TextView's height is just enough), the second task I find very hard. The only solution I came up with till now is to wrap TextView into some layout and set it's y position to negative - it would be OK, but I need to care about optimization because there will be many digits animated in that way simultaneously.
Do any of you know how to achieve this in more effective way?
What about overlaying the top textview OVER the bottom textview (maybe with the white spacer as well?

Categories

Resources