[英]Android how to use list view child in parent scroll view when scroll view child have weight
[英]How to stop the scrolling of parent scroll view when child scroll view is scrolled in android?
我知道我們可以在兩個滾動視圖中使用touchlisteners
parentScrollView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Log.v(TAG, "PARENT TOUCH");
findViewById(R.id.child_scroll).getParent()
.requestDisallowInterceptTouchEvent(false);
return false;
}
});
childScrollView.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;
}
});
我面臨的是我的子滾動視圖不是父滾動視圖的直接子視圖。在此v.getParent()
不起作用,當我觸摸並嘗試滾動我的子滾動視圖時,整個主滾動滾動。
我的滾動視圖在我的布局中的位置(視圖是動態創建的,因此我需要使用這么多布局)
linearLayout
ParentscrollView(0)
linearLayout(0)
relativeLayout(0)
TextView(0)
relativeLayout(1)
childScrollView(0)
需要幫助。謝謝。!!
是不是findViewById()
父滾動視圖ID不起作用?
childScrollView.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
findViewById(parentLayouttId).requestDisallowInterceptTouchEvent(true);
return false;
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.