在我的应用程序中,我必须在scrollview中实现scrollview。我知道使用嵌套的scrollview是不好的做法,但我的应用程序需要它。
我在各个地方找到了解决方案,以拦截如下事件:
parentScrollView.setOnTouchListener(new View.OnTouchListener() {
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() {
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;
}
});
但它也没有用.IF任何人都面临同样的问题并有一些解决方案。请提供给我。
我的布局结构如下:
<ScrollView
android:id="@+id/scroll"
android:layout_width="match_parent"
android:focusableInTouchMode="false"
android:layout_height="wrap_content"
android:layout_below="@id/topLayoutSaveSchedule"
android:layout_marginBottom="52dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/linearLayoutAndroidMess"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="horizontal" >
<CheckBox
android:id="@+id/checkBoxAndroidMessag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Copy Sent SMS to Android Messaging"
android:textColor="@color/Black" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:gravity="center_vertical"
android:text="Selects Contacts:"
android:textColor="@color/Black"
android:textSize="14dp" />
<ScrollView
android:id="@+id/scrlView"
android:layout_width="150dp"
android:layout_height="200dp"
android:gravity="top"
android:scrollbars="vertical" >
<LinearLayout
android:id="@+id/linLayout"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp"
android:orientation="vertical"
>
</LinearLayout>
</ScrollView>
<Button
android:id="@+id/addContacts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/group_add" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:gravity="left"
android:text="Message:"
android:textColor="@color/Black"
android:textSize="14dp" />
<EditText
android:id="@+id/text"
android:layout_width="150dp"
android:layout_height="15mm"
android:layout_marginLeft="8mm"
android:layout_marginTop="10dp"
android:gravity="top"
android:inputType="textMultiLine" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:orientation="vertical" >
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/select_date_time"
android:textColor="@color/Black"
android:textSize="14dp" />
<DatePicker
android:id="@+id/datePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp" />
<TimePicker
android:id="@+id/timePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="Repeat/Recurring Option:"
android:textColor="@color/Blue"
android:textSize="20dp" />
<Spinner
android:id="@+id/spinner1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp" />
<Button
android:id="@+id/saveScheduledText"
android:layout_width="25mm"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="20dp"
android:layout_marginTop="10dp"
android:background="@drawable/button_style"
android:gravity="center"
android:text="@string/save_scheduled_msg"
android:textColor="@color/White" />
</LinearLayout>
</LinearLayout>
</ScrollView>