Well I have in the main_layout a pulltorefresh viewgroup inside of that layout I have two fragments - One of these fragments has a ScrollView layout - so basically one fragment has an image and the other is scrollable with a bunch of details. I use this code to disable the pulltorefresh from intercepting the touch events that are made on the scrollable fragment part:
descriptionScrollView = (ScrollView) findViewById(R.id.detail_item_description_holder_scroller);
descriptionScrollView
.setOnTouchListener(new View.OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
// Disallow the touch request for parent scroll on
// touch of child view
descriptionScrollView
.requestDisallowInterceptTouchEvent(false);
pullToRefreshScrollView.getRefreshableView()
.requestDisallowInterceptTouchEvent(true);
return false;
}
});
This blocks the pulltorefresh from scrolling when I touch on the scrollview part of the screen - the only problem is that the scrollview layout is not scrollable at all. When I remove the PulltoRefresh from my main_layout this scrollview from fragments layout becomes scrollable..
Please help
Related
I'm facing problems in scrolling. I've the following structure in order in my project:
1) ViewPager
2) RecyclerView
3) ExpandableListView
I cannot scroll the ExpandableListView; but I can scroll RecyclerView. I tried setNestedScrolling but i didn't work.
Any solutions?
I think what you need to do is disable the scroll of the parent when you touch the child. So this should work
mListView.setOnTouchListener(new View.OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
//Disallow the touch request for parent scroll on touch of child view
v.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});
I have an issue making 2 nested vertical RecyclerViews. I know this isn't a great pattern, but these are the application requests.
I have a parent RecyclerView, and when a card expands it should scroll to top and in the expanded part, I have another RecyclerView (a list of locations).
The problem is that I couldn't pass the scroll event from the parent, to the child RecyclerView. I read about the NestedScrollingChild interface and tried to enable nestedScrolling in child, but with no success.
Any suggestions?
I fixed it by adding the following code on my main RecyclerView adapter. Works perfectly.
holder.locationsList.setOnTouchListener(new View.OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
Log.v(TAG, "CHILD TOUCH");
// Disallow the touch request for parent scroll on touch of child view
v.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});
I am developing an app which it has a vertical ViewPager within ScrollView. The thing is ViewPager only recognize touch events when I scroll horizontally, otherwise ScrollView will get focused and perform the scroll.
I think this could work:
viewPager.setOnTouchListener(new View.OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
scrollView.requestDisallowInterceptTouchEvent(true);
int action = event.getActionMasked();
switch(action){
case MotionEvent.ACTION_UP:
scrollView.requestDisallowInterceptTouchEvent(false);
break;
}
return false;
}
});
But because of ViewPager does not recognize touch events when I perform vertical scroll this piece of code does nothing.
What I want to achieve is give focus to ViewPager when I touch it and give focus to ScrollView when I'm not touching the ViewPager. Thanks in advance.
This is some code I use for a scrollview that has problems with textviews focusing. It might help you. It might not.
ScrollView sv = (ScrollView) view.findViewById(R.id.svRecord);
sv.setOnTouchListener(this);
sv.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
sv.setFocusable(true);
sv.setFocusableInTouchMode(true);
Hi in my application the screen is so large which contains a gridview with images and listview with lot of list items and also so many text views existed in my screen. so that i placed this content in scrollview to view on the mobile screen. When I placed the content in the scrollview then the gridview/listview scroll is not working.
Is there any way to solve this issue. I referred so many links but i could not get the solution.
The links are
Grid of images inside ScrollView
How can I put a ListView into a ScrollView without it collapsing?
etc
You can solve it using following code, but I suggest please change UI, it is not according android guideline. it' easily scrolled in iPhone interface.
final ScrollView childScroll = (ScrollView)
view.findViewById(R.id.resourceactivity_sv_classes_detail);
parentScroll.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
//Log.v(TAG,"PARENT TOUCH");
childScroll.getParent().requestDisallowInterceptTouchEvent
(false); return false; } }); childScroll.setOnTouchListener(new
View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
//Log.v(TAG,"CHILD TOUCH");
v.getParent().requestDisallowInterceptTouchEvent(true); return
false; } });
You can modify gridview instead of child scrollview.
I am having scrollview inside another scrollview. I want to scroll inner scrollview but outer scrollview is only scrolled.how to solve this problem?
Thanks.
sv01 = (ScrollView) findViewById(R.id.popup_sf_event_scroll_01);
sv02 = (ScrollView) findViewById(R.id.popup_sf_event_scroll_02);
sv02.setOnTouchListener(new OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP)
sv01.requestDisallowInterceptTouchEvent(false);
else
sv01.requestDisallowInterceptTouchEvent(true);
return false;
}
});
in scroll view take one layout and add another scrollview in that layout coz scrollview can hold only one child in it. So that inner scrollview can move for what it is holding in it.