I need to draw text on a TextView in a bottom up fashion, i.e., draw the last line of the text first at the bottom, then the second last line of the text and so on. How can I do that?
I am trying to follow the solution given in this post - Paginating text in Android.
TextView draws the text top down. What I want to achieve is given a text, I would like the last line of the view filled first, then the second last line and so on, Hence filling the first line in the last iteration. I tried creating a Custom TextView and overriding its onDraw method, but nothing seems to work.
Create a custom textview. In the setText method, do some string manipulation. Basically rearranging the text in the string so that the first line I the new text string is the last line of the old text string. Pass the new text string to the super.setText
If it is not scrollable textview you can set android:gravity="bottom|left" or "bottom|right" if you want right alignment. With this method width and hight can't be wrap_content.
Related
is there any way to make a design like this (image)
EXPLANATION:
List of items where item take its width if screen widths are not fit so continue in next row.
Item(2) starts after the item(1) and continues in the next row.
Items will be textviews
flexlayout has limit if item will not fully fit it make it in another row
Edit:
(Assume Case )
assume I have two texts and want to display them
for ex text1 = "Hello ", text2 = "Ahmed"
and screen width can fit 8 character
so UI should be
Hello A
hmed
[Actual Case]
here there are two texts , first with below background and second without this is final UI
A small example for assuming the case
input: Hello Ahmed
expected output :Hello A
hmed
You can store a list of strings into single string. Make text view height wrap content using Spanable string, you can have more control on text.
You can achieve that by adding android:scrollHorizontally="false" to the TextView xml that is displaying the text.
<TextView
.
.
.
android:scrollHorizontally="false" />
I have an EditText that consists of a spannable string.
The spannable string shows its spans as BitmapDrawables (converted from a linear layout).
At all points, I want the EditTexts height to be exactly as big as it has to be to show the whole content:
It grows as i enter more text, but making a span at the end of the line doesnt make it grow.
The third tag that is being cut off in the following screenshot was added to the text after the second tag. The edittext did not resize in this case. (I scrolled to the first line, as you would only see the third tag directly after entering it)
How can I make sure the edittext grows as the content increases?
Its vertical layout param is set to wrap_content.
Vertical layout param is NOT match_parent, as the edittext would be bigger than one line when it is empty.
EditText: (C#)
.SetSingleLine(false);
.SetMaxLines(10);
.SetMinLines(1);
InputType = InputTypes.ClassText | InputTypes.TextFlagMultiLine,
movementMethod = new ClickableMovementMethod(); //Custom MovementMethod inheriting from LinkMovementMethod
.SetScroller(new Scroller(Context));
.VerticalScrollBarEnabled = true;
.SetScrollContainer(true);
I have a simple layout in a table that consists of 3 rows. The second column may have either an EditText or a TextView like in the picture below:
Now, my question is how can I align the start of the text in EditText and TextView so that they are visually under each other (the texts, not the controls)? In the image above, the text in the second line starts too much to the left. I don't want to hardcode the padding as it may not work the same way on different devices.
try setting a padding for the second textview.
android:padding="5dp"
Instead of making the TextView match the EditText, make the EditText match the TextView by making its background null:
<EditText ... android:background="#null" ... />
The underline in the EditText then goes away and everything lines up perfectly.
I need to create an animation in Android. I have 3 TextViews placed in an LinearLayout. All I want to do is the text field must come on to the screen as though it has been pulled out from the left end of the screen. Something similar to a marquee, however the text field must come from left end of screen one character at a time to occupy the left end of screen.
you must textView set textview property in your xml layout android:ellipsize="marquee" and you oncreate() method to set textview like youtextview.setSelected(true); now your textview running with marquee effect perfectly work for me!
another way you can add dynamically textview in coding you can follow this code:
yourtextview.setEllipsize(TruncateAt.MARQUEE);
yourtextview.setSelected(true);
I would like to locate a view just after the last word of a (potentially) multi-line TextView.
For example, the TextView might be two lines, with the second line being about half as long as the TextView's width. How do I locate a View just after the last word?
You can use a StaticLayout to measure the width of your text lines and place your other view at the absolute position of the the second line length.
Alternatively you could use HTML in your TextView to place some elements inside your view.
myTextView.setText(Html.fromHtml("<h2>Title</h2><br><p>Description here</p>"));
Supported html tags: http://commonsware.com/blog/Android/2010/05/26/html-tags-supported-by-textview.html