Height of TextView is not increasing beyond screen height - android

Problem : While adding text to a text view in android , when text is long enough to make textview height greater than screen, the textview is only increasing its height up to the screen height and not going beyond the screen.
Requirement: To increase the height of text view according to the text content .
Is it possible to change the height of a text view at runtime?
EDIT
Even though I change the height of TV (greater than height of screen) in XML
still my TV height is not exceeding screen height.
EDIT 2
I achieved this by drawing the TextView using canvas. I am not sure how efficient this is.

Related

90º rotated textview gets size to display text as the horizontal space

I have a textview where I want to show text in vertical (just like rotated 90º). With android:rotation="-90" you can get this.
If the text would have no rotation, and you would like to fit a sentence, you would first look at the width of the textview, since text will try to be in 1 line. Since I rotate the text, here I expect to see the height of the object. However, Android is still considering the width. I need to fix the size of the width, but this causes me a problem for the text: Although the textview has a big vertical dimension and text would fit, Android thinks it needs to use the width to calculate the available space. At the end this causes me overflow of the text, appearing for example, just one word as multiple lines of 1 char.
How can I make android to understand that the space for the lenght to fit the text is now the vertical, instead of the horizontal?

Dynamic height of ImageView in scrollView

I am trying to add 3-4 imageviews in a scroll view. Imageviews have dynamic heights. Height of first view have 70% of the screen and second and third have 30% height. I am using constraint layout and guidelines but the height is getting set according to the height of the scroll view but not according to the screen height. Is there a way to do this with constraint layout.
Have you tried doing it programmatically?
First, get the Screenheight for your device: How to determine the screen width in terms of dp or dip at runtime in Android?
Secondly, get your Imagview and set its height according to xx% of the determined screen height.
BR

Set Text width more than Display width

I thought that maximum width of a text View in android is display width of the device.I have scroll text that is extended from Linear Layout.By using animation class i can move the text, and its act like a automatic Scrolling text. My problem is the text length(String length 70) exceed the maximum width of the text view (1280 pixel). So the text 70 is show like this (...)
To make a TextView Scrollable the setMovementMethod() has to be called. However, there will be no scroll bar when scrolling it. To add a scroll bar, the android:scrollbars attribute has to be set in the layout file like this:

Resizing the textview size based on the screen width for all devices

I have problem in resizing the text view .
I have a Layout like this with below components
ImageView| TextView | ImageView
placed in relativelayout(horizontal) and each one width is wrap content and height is fill parent.
PROBLEM
I have a text like this "My name","My name is xyzmnop" now, i have fixed the TextView size to 15sp, so what is happening is in larger devices since Textviews width increases the text "My name is xyzmnop" will fit but in smaller devices since the width is small it will spill out to second line. But i want it to be in same line, as I have the flexibility to decrease the size of the text if the text is lengthy.
please help me with this problem.
i have seen this
Android TextView doesn't resize after changing text size
Android EditText Resize Programatically
Resizing TextView does not shrink its height on Android 3.1
EDIT:
I have also added setSingleLine = "true"; in my xml
Say, tv is your TextView.
Just call tv.setMaxLines(1);
TextView has the setMaxLines (int maxlines) method:
Makes the TextView at most this many lines tall. Setting this value overrides any other (maximum) height setting.
I suppose this might help you if you set the maximum number of lines to 1.
Note: there is also the android:maxlines attribute if you need to set it in your XML layout.
i have solved it using ViewTreeObserver.

Adapt text size depending on the size of the layout

I have 4 TextViews placed horizontally filling all the width of the screen, and each TextView with the same horizontal width . Depending on the device's screen the total width is diferent. I want to change the textsize to fill each TextView horizontally but in a manner that the text fits. Is there any way to do this?? Thx
I think that this link could help you immensly as it is very similar. You may have to SET your widths static based upon you screen width then continue to adjust your font size until the vertical direction fits for each textview.
Calculate text size according to width of text area

Categories

Resources