Rectangle 27 90

This is happening because UIButton subviews of the UIScrollView (I assume buttons are added as subviews in your case) are tracking the touches and not the scroll view. UIScrollView method touchesShouldCancelInContentView is the key here. According to its description: "The default returned value is YES if view is not a UIControl object; otherwise, it returns NO.", i.e. for UIControl objects (buttons), UIScrollView does not attempt to cancel touches which prevents scrolling.

canCancelContentTouches
UIScrollView
touchesShouldCancelInContentView
YES
UIButton
- (BOOL)touchesShouldCancelInContentView:(UIView *)view
{
    if ( [view isKindOfClass:[UIButton class]] ) {
        return YES;
    }

    return [super touchesShouldCancelInContentView:view];
}

thank you for your answer. I changed the scroll having images to simulate buttons (and tracking touches to know when to call a method) I will try your solution though and see how it works. thanks!

It still doesn't work for me. touchesShouldCancelInContentView is never called, unless I set the delay to NO, but in the latter case, there is no scroll at all.

I added an example. Note that I would actually check for UIControl instead of UIButton, in case a slider or stepper or switch showed up at some point.

The issue persists again in iOS 8 and touchesShouldCancelInContentView is not working anymore. But, the scrolling stuck only sometimes. Not always.

ios - ScrollView not scrolling when dragging on buttons - Stack Overfl...

ios cocoa-touch uiscrollview uibutton ios-simulator
Rectangle 27 8

I founded this question looking for the swift solution for this problem, I "translated" it like this:

class UIButtonScrollView: UIScrollView {

    override func touchesShouldCancelInContentView(view: UIView!) -> Bool {
        if (view.isKindOfClass(UIButton)) {
            return true
        }

        return super.touchesShouldCancelInContentView(view)

    }

}

ios - ScrollView not scrolling when dragging on buttons - Stack Overfl...

ios cocoa-touch uiscrollview uibutton ios-simulator
Rectangle 27 23

Is the goal just to have a scrollable area that takes up the entire page minus the amount taken up by some buttons at the bottom?

If that's the case, you can use a LinearLayout at the outer level and make use of weights:

<LinearLayout 
   android:layout_height="wrap_content" 
   orientation="vertical"...>
   <ScrollView
      android:layout_height="0dp"
      android:layout_weight="1"
      .../>
   <LayoutWithButtons
      android:layout_height="wrap_content"
      ..../>
</LinearLayout>

Sorry, I guess it was not clear... added a sketch...

Hmm, what happens if you set the outer LinearLayout to wrap_content? If that doesn't work on its own, wrap it in another LinearLayout with a greedy (height=0, weight=1) invisible element below it?

It still expands and pushes the buttons out of the screen...

Setting the outer Layout with wrap_content worked. If I add the other greedy invisible Layout, the buttons would be stuck in the middle of the screen. But you got it.. thanks !

I'm getting an error that layout_height="0" is not a valid value, but using wrap_content seems to work perfectly.

android - buttons below expanding scrollview - Stack Overflow

android user-interface android-layout
Rectangle 27 3

override func touchesShouldCancel(in view: UIView) -> Bool {
    if view is UIButton {
        return true
    }
    return super.touchesShouldCancel(in: view)
}

ios - ScrollView not scrolling when dragging on buttons - Stack Overfl...

ios cocoa-touch uiscrollview uibutton ios-simulator
Rectangle 27 2

In the end, I found the following solution did exactly what I needed:

@Override
public boolean onTouchEvent(MotionEvent ev)
{
    App.log("onTouchEvent, with action : " + ev.getAction());
    switch(ev.getAction())
    {
        case MotionEvent.ACTION_MOVE:
            return false;
    }
    return super.onTouchEvent(ev);
}

Disable Android scrollview, but still allow taps on buttons in the scr...

android scrollview ontouchevent
Rectangle 27 1

You can override overscrollBy() and change the deltaX & deltaY values to 0 if disabled.

@Override
protected boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent)
{
    final int dx;
    final int dy;

    if (isEnabled())
    {
        dx = deltaX;
        dy = deltaY;
    }
    else
    {
        dx = 0;
        dy = 0;
    }

    return super.overScrollBy(dx, dy, scrollX, scrollY, scrollRangeX, scrollRangeY, maxOverScrollX, maxOverScrollY, isTouchEvent);
}

You'll probably also want to dynamically hide/show the scroll bar too on disabling/enabling.

Hmmm... doesn't seem like the right answer, surely there's a way to stop the scrolling at the beginning without worrying about this 'overscroll' busines (and couldn't I just disable over-scrolling anyway with setOverScrollMode?)

ScrollView performs its scrolling using that method. Admittedly it's hardly a perfect solution, but without a specific allowScrolling(boolean) or similar on ScrollView's interface to perform what you want, I think it's as good as any other method.

Disable Android scrollview, but still allow taps on buttons in the scr...

android scrollview ontouchevent
Rectangle 27 1

I have some very specific customized needs for a keyboard solution -- requiring me to handle the display and tear-down of the keyboard on my own as a z-layer element in a frameLayout. I use the solution in that link to accomplish that and change the size of the scrollView at the same time. The buttons in the scroll view move from flush with the bottom of the screen to flush with the top of the keyboard.

The key is having android:fillViewport="true" on the scrollView. Then programmatically setting the bottom margin of the scrollView to and the top margin of the bottom element to -height.

private void setMargins_noKeyboard()
{
    ScrollView fieldsScroller = (ScrollView)findViewById(R.id.scroll_fields_view);
    FrameLayout keyboardFrame = (FrameLayout)findViewById(R.id.keyboard_root);
    int buttonsKeyboardSize = keyboardFrame.getHeight();

    MarginLayoutParams frameParams = (MarginLayoutParams)keyboardFrame.getLayoutParams();
    frameParams.setMargins(0, 0, 0, 0);

    MarginLayoutParams scrollParams = (MarginLayoutParams)fieldsScroller.getLayoutParams();
    scrollParams.setMargins(0, 0, 0, 0);

    keyboardFrame.setLayoutParams(frameParams);
    fieldsScroller.setLayoutParams(scrollParams);
}

private void setMargins_keyboard()
{
    ScrollView fieldsScroller = (ScrollView)findViewById(R.id.scroll_fields_view);
    FrameLayout keyboardFrame = (FrameLayout)findViewById(R.id.keyboard_root);
    int buttonsKeyboardSize = keyboardFrame.getHeight();

    MarginLayoutParams frameParams = (MarginLayoutParams)keyboardFrame.getLayoutParams();
    frameParams.setMargins(0, -buttonsKeyboardSize, 0, 0);

    MarginLayoutParams scrollParams = (MarginLayoutParams)fieldsScroller.getLayoutParams();
    scrollParams.setMargins(0, 0, 0, buttonsKeyboardSize);

    keyboardFrame.setLayoutParams(frameParams);
    fieldsScroller.setLayoutParams(scrollParams);
}

After working with this quite a bit more, I have found that while the above answer works there is a better solution. Using a relative layout works very reliably without all the programatic gyrations of this answer. The key is at least one element that aligns with parent top and one element that aligns with parent bottom. The rest of the elements align relative to these two, the scrollview ultimately is sandwiched between anything that needs to remain stationary.

android - buttons below expanding scrollview - Stack Overflow

android user-interface android-layout
Rectangle 27 0

You should place your LinearLayout inside the ScrollView, because ScrollView is a container and its children are scrollable. Also, set the ScrollView as the activity's content view and define its layout params.

ScrollView scrollView = new ScrollView(this);
scrollView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
scroll.addView(mLinearLayout);
setContentView(scroll);

I am confused can you show me how to do it?

Could you please post the XML where you defined the LinearLayout "R.id.linear1"?

I will post it and what you suggested did not work either :/

android - Add a button within a ScrollView - Stack Overflow

android button radio-button scrollview
Rectangle 27 0

Have you considered putting an invisible layer on top of the view that intercepts touches, making sure that it returns "true"?

Make it so that the button event listener generates this layer when pressed.

Just a thought. Best of luck. :)

In Corona Sdk, i have a button in a scrollView. when touch the button....

button scrollview corona
Rectangle 27 0

ScrollView must have 1 child. So put the two buttons inside a layout.

java - Can someone explain why I can't add an extra button to this Scr...

java android button scrollview
Rectangle 27 0

In case this helps someone else.....

All the Activities that were hosted inside the TabHost had android:windowSoftInputMode = adjustPan.

However, the Activity that hosted the TabHost was missing android:windowSoftInputMode = adjustPan. Once I added that, the panning worked the smae inside a TabHost or outside the TabHost.

android - ScrollView with Button Below Scrolls Different Inside TabHos...

android scroll scrollview android-tabhost
Rectangle 27 0

Check out that your button 2 is inside the bounds of scrollview. If button's any part will lie outside the parent container's frame, it will not respond to any events. Test it by changing color of background of the scrollview. Also you can set button2.clipToBounds = YES. If button will be out of bounds, that part will be clipped.

objective c - Button click not responding in ScrollView when I create ...

ios objective-c uiscrollview uiscrollviewdelegate
Rectangle 27 0

it means both of your layouts are interdependent on each other.

I have tried setting the layout_width for Linear layout to "fill_parent" but that doesn't help either. Those button inside the scrollview is still having unequal width.

just remove the weight attribute. either hardcode the width of the buttons or set it to wrap-content.

Look like there is no choice but to hardcoded the width then. Thanks, it work after i hardcoded it and remove the weight attribute.

android - Unable to set the weight of buttons inside scrollview - Stac...

android scrollview
Rectangle 27 0

You must have your layout inside a ScrollView.

getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

android - ScrollView doesn't scroll up to the top after going through ...

android android-dialogfragment android-keypad
Rectangle 27 0

The button is not clickable because it is below the frame of the content view. You need to remove all auto layout constraints from your content view (the UIView inside the scrollview).

Then you can add all the objects that you need to add to the content view and set the height of the content view according to the height of the content.

So lets say that you calculated a height of 1000 for the content of the objects in the scroll view. You would then need to set the frame of the content view like this:

contentView.frame = CGRectMake(0,0,scrollView.frame.size.width, 1000);

And don't forget to set the contentSize for the scrollview so that the scrollview knows how much room it needs to scroll.

uiscrollview - iOS Autolayout storyboard ScrollView - button bottom of...

ios uiscrollview autolayout
Rectangle 27 0

This is happening because UIButton subviews of the UIScrollView (I assume buttons are added as subviews in your case) are tracking the touches and not the scroll view. UIScrollView method touchesShouldCancelInContentView is the key here. According to its description: "The default returned value is YES if view is not a UIControl object; otherwise, it returns NO.", i.e. for UIControl objects (buttons), UIScrollView does not attempt to cancel touches which prevents scrolling.

canCancelContentTouches
UIScrollView
touchesShouldCancelInContentView
YES
UIButton
- (BOOL)touchesShouldCancelInContentView:(UIView *)view
{
    if ( [view isKindOfClass:[UIButton class]] ) {
        return YES;
    }

    return [super touchesShouldCancelInContentView:view];
}

thank you for your answer. I changed the scroll having images to simulate buttons (and tracking touches to know when to call a method) I will try your solution though and see how it works. thanks!

It still doesn't work for me. touchesShouldCancelInContentView is never called, unless I set the delay to NO, but in the latter case, there is no scroll at all.

I added an example. Note that I would actually check for UIControl instead of UIButton, in case a slider or stepper or switch showed up at some point.

The issue persists again in iOS 8 and touchesShouldCancelInContentView is not working anymore. But, the scrolling stuck only sometimes. Not always.

ios - ScrollView not scrolling when dragging on buttons - Stack Overfl...

ios cocoa-touch uiscrollview uibutton ios-simulator
Rectangle 27 0

I founded this question looking for the swift solution for this problem, I "translated" it like this:

class UIButtonScrollView: UIScrollView {

    override func touchesShouldCancelInContentView(view: UIView!) -> Bool {
        if (view.isKindOfClass(UIButton)) {
            return true
        }

        return super.touchesShouldCancelInContentView(view)

    }

}

ios - ScrollView not scrolling when dragging on buttons - Stack Overfl...

ios cocoa-touch uiscrollview uibutton ios-simulator
Rectangle 27 0

In the end, I found the following solution did exactly what I needed:

@Override
public boolean onTouchEvent(MotionEvent ev)
{
    App.log("onTouchEvent, with action : " + ev.getAction());
    switch(ev.getAction())
    {
        case MotionEvent.ACTION_MOVE:
            return false;
    }
    return super.onTouchEvent(ev);
}

Disable Android scrollview, but still allow taps on buttons in the scr...

android scrollview ontouchevent
Rectangle 27 0

If you are trying to create a view where the upper portion of the screen is a scrolling list, and the bottom portion is a button, put the scrollview inside a linearlayout, and put the button in the linearlayout below the scrollview.

Set ScrollView + Fixed Button Programatically on Android with setText....

android scrollview css-position
Rectangle 27 0

You should remove this from you Xml

overScrollmode="never"

already tried that. doesn't work. i think the problem here is, when the keyboard is open and i have moved down to one of the editexts which accepts text, then if i try to scroll up it stops where it is not supposed to take text as input (the one above "scrollupStopsHere: edittext take numbers as input).

android - ScrollView doesn't scroll up to the top after going through ...

android android-dialogfragment android-keypad