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:
Related
I'm trying to create this kind of layout in android.
I'm using constraint layout. I want to divide the screen with height y to two halves with y/2 height each.
Each one of them will have a textview as title which takes the whole width and has constant height.
And a circular custom view which I would like to expand or shrink so it fills the whole half so the padding marked as 'auto' will all be the same but dynamic.
And p will be a minimum padding that the view can't be over them.
The aspect ratio should of those circles should not be changed.
Is that even possible doing it in the xml design editor? or do I have to do it programmatically.
Next step will be to arrange those halves to be side by side if it's a landscape view.
OK, I did it, Basically you drag the 4 edges of a each view to center it in the outside element. And set the margins to .
So I dragged title2 to all directions of the screen and it got centered. Then I dragged each of the circular views edges the same way so the upper view I dragged to title1 and the bottom to title2. The bottom view I dragged its top to title 2 and the bottom to the bottom of the screen.
Auto resizing is done by setting layout_width to 0 and layout_height 0.
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.
I set the button's height via XML. Suppose it to be X
<Button
android:layout_height="wrap_contnet"
android:textSize = " <X> dp"
....
....
/>
If I set X to greater than 15 dp, the button's height grows to fit the text. But when I set it to something lower like 2dp, the button's height doesn't change and I can see a thick border around it as shown below:-
As shown above, text size is so small but still height doesn't decrease!
How can I force it to be of appropriate height?
Thanx in advance!
Font size does not depend on button height. If you set it too small to fit the text, you will get the result you observe
EDIT
wrap_content would usually do the trick, however Button class sets some layout parameters like margin, background so it takes more space. You may get rid of Button and use i.e. TextView class, styled by hand to match your design. onClickListener will work perfectly fine with it and you will get result you want and full control over your button
EDIT 2
As this is bit related - there's AutoFitTextView widget on Github that deals with automatic text size scalling: https://github.com/grantland/android-autofittextview
Just Set android:minHeight="xxdp"
What do I have to use to create a text input like evernote's?
It's look like they are using two edittext to create this, but even if I can have the same style for the upper part (whith one edittext), I don't know how to do the bottom part: it's look like the edittext is divided in two part, and the bottom part is taking the full screen.
Do I have to create some custom view?
It is easy. There are three main elements.
EditText with specified height (18sp for example) and width match_parent,
no padding/margin, 1dp height, match_parent width View element,
EditText with no padding/margin, width match_parent, specified height (36sp for example)
They also use hint option to display text in EditText, and View background color same as hint text color.
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