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);
Related
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.
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
I have a RelativeLayout whose layout_height is set to "wrap_content" and inside that I have a TextView whose text is set at runtime. I have set android:layout_height="wrap_content" to my TextView, but it doesn't seems to change the height of the Textview even if the content is larger than 1 line.
It only takes the height of single line and displays 1 line, and all the remaining lines appears to be marquee vertically which is seen when I drag it manually...
so what will be the issue?
change property of textview Input Type:textMultiline
You can use also this
textView1.setText(Html.fromHtml("Titleeee"));
here i found a list of text that fromHtml will convert
http://commonsware.com/blog/Android/2010/05/26/html-tags-supported-by-textview.html