Scrollable EditText at AndroidStudio - android-edittext

so I'm trying to create a simple scrollable layout and a scrollable edittext's within the layout.
Scrollable layout works perfectly with ScrollView layout.
I've read about EditText scroll to implement this code -
android:inputType="textMultiLine"
android:lines="10"
android:minLines="1"
android:scrollHorizontally="false"
android:scrollbars="vertical"
But when I run the app on my phone and I try to scroll up within the EditText, it scrolls the layout (Using the ScrollView layout), instead of scrolling the EditText.
Anyway suggestions?
Thanks alot!

I think by not setting the height of the EditText to wrap content will help you.
Either try setting height to match parent or set height in DP's.

Related

Why there is no possibility of scrollview scrolled when added contents dynamically.?

I am using scroll view. In my scenario, When contents are added dynamically in content view of scroll view. The view height must be increased automatically and content is added to the bottom with scrolling functionality. I tried the following. There is no particular way of scroll functionality. I don't know why scrolling is much complicated in iOS. Why scroll view not work the way like table view scrolling, table view taking any number of amount and scrolls. Finding youtube videos too not working as it has fixed height in advance .
Inside your scrollview you must add a UIView. Add a height constraint to the UIView and programatically change the height of the UIView depending on the content you are adding to this UIView. This scrollview will work if the height is large.

How to make UIScrollView height dynamic from storyboard with the new Safe Layout feature?

I used to make my scroll views have dynamic height using auto layout constraints (adding a content view to the scroll view to hold all the views and pinning them etc.) But now as with the new Safe Layout feature, I cannot achieve the same dynamic height scroll view behavior despite all my trials.
All I want is a scrollable screen with an image at the top, with title and text labels below whose content is not known beforehand.
I hope I could explain my problem well enough. Thank you all!
Cheers,
Murat

iOS - Links on UITextView don't work with UIScrollView

I have a UITextView on a UIScrollView. The text view contains a few links.The links don't work if the text view is originally outside screen and scrolled into view. If the textview is originally in the screen, the links work fine.
Anyone knows the solution for that?
I got the solution myself. It was the height of the content UIView on the UIScrollView that was making the problem. The content view's height was equal to the scrollview's height. But, the subviews' total height was a lot larger. Although everything seems displayed correctly, user interactions outside the content view's bounds was not passed to subviews properly.
So, I override viewWillLayoutSubviews and manually update the content view's height constraint. The links are working fine now.

Detect a UIScrollView's height dynamically

I have a real problem with detecting UIScrollView height. I searched a lot and found this solution:
So I dragged from Content View to View and made Equal Height. But I does not work for me.
I also tried to calculate scrollView height according to elements height in it, but I do not think that it's a right way.
How can I set UIScrollView height dynamically? What is the correct way for doing it?
Your ScrollView should add a ContentView like this:
select your scrollView and in size Inspector bottom, set the width like this:
for more details on how to handle scrollView in Interface Builder your can check out this AppleDoc Working with Scroll Views
Hope this help you!
You only way to set height of your scrollView is by calculating the height of individual objects added to scrollview.
Programatically, calculate the height of each UI object and at the end set content height to scrollview.
[scView setContentSize:CGSizeMake(300, height)];
In above line, 'height' is nothing but a sum of all heights of all UI objects calculated.
By doing the below stuff's, I was able to implement UIScrollView with Automatic height based on the contents inside.
Add scrollview to the main view.
Add one ContentView inside this container scroll view.
Give proper constraints inside this content
view to the container scroll view as well as to its internal UI
Components. Please note that you should not give fixed height to the
content View. The constraints of the content view should grow
according to the UI Components inside
This might give you a layout
warning as 'Unambigous.... '. To fix this, give 'Equal Heights' constraint relation between content view and scroll view
Try the above steps, and this will solve your issue :)
Do you want to add item (UIView, UILabel...) in your UIScrollView by auto layout? If so, just put these in it and create correct constraints for them.
The key point is each item which in UIScrollView have top, leading, bottom and trailing side constraints to their superview. Most important is Make Sure that your UIScrollView has top, leading, bottom and trailing Descendant Constraints to its sub-items. It will calculate correct content height of scroll view for you.
In your solution, if your contentView has zero frame, it will not give you any height for scroll view.

UIScrollView auto layout not working the width of contentView

i'm back developing IOS after a year and a half. I'm really having difficulty in make use of UIScrollView and auto layout.
I'm developing an application running just in Iphone and portrait orientation.
I have a simple form inside my content view...
label
textField
textField
textField
textField
button
textField
view
imageView
label
The problem is with the width of the contentView's content. The size is been defined for the labels. I would like (And really have to do) o size it according with the screen size.
Here is my constraints of my first text field:
Here is my simulator screen running the app:
how I mentioned before, it seems to get the size according the label and not according the screen size. If I create a constraint of size for the first label, this size change but I would like to get the size dinamically based on screen.
I didn't write any code, I want to do it preferentially using auto layout to understand the concepts of auto layout better.
If someone could help me to solve it... I would be very grateful.
Pin your contentView.width equal to scrollview.width.
Add a constraint to your scroll view's content view child to be the same width as the root-level view.

Resources