Layout File
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:id="@+id/activity_main_parent_scroll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:color/black"
android:focusableInTouchMode="true" >
<LinearLayout
android:id="@+id/activity_main_linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ScrollView
android:id="@+id/activity_main_child_scroll"
android:layout_width="fill_parent"
android:layout_height="@dimen/widthsize100"
android:focusable="true"
android:focusableInTouchMode="true" >
<TextView
android:id="@+id/activity_main_activity_main_text_description"
style="@style/Textview" />
</ScrollView>
<TextView
android:id="@+id/activity_main_activity_main_text_description_3"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_4"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_5"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_6"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_7"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_8"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_9"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_10"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_11"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_12"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_13"
style="@style/Textview"
/>
<TextView
android:id="@+id/activity_main_activity_main_text_description_14"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_15"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_16"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_17"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_18"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_19"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_20"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_21"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_22"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_23"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_24"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_25"
style="@style/Textview" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
style.xml
<style name="Textview">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:scrollbars">vertical</item>
<item name="android:text">@string/text</item>
<item name="android:textColor">@android:color/white</item>
<item name="android:textSize">@dimen/textsize12</item>
<item name="android:padding">@dimen/padding5</item>
</style>
string.xml
<string name="text">sdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfh</string>
dimen.xml
<dimen name="textsize12">12dip</dimen>
<dimen name="padding5">5dip</dimen>
<dimen name="widthsize100">100dp</dimen>
MainActivity.java
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ScrollView;
public class MainActivity extends Activity {
ScrollView mScrollViewParent;
ScrollView mScrollViewChild;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mScrollViewParent=(ScrollView)findViewById(R.id.activity_main_parent_scroll);
mScrollViewChild=(ScrollView)findViewById(R.id.activity_main_child_scroll);
mScrollViewParent.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
Log.v("A","PARENT TOUCH");
// findViewById(R.id.child_scroll).getParent().requestDisallowInterceptTouchEvent(false);
mScrollViewParent.getParent().requestDisallowInterceptTouchEvent(false);
return false;
}
});
mScrollViewChild.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event)
{
Log.v("B","CHILD TOUCH");
// Disallow the touch request for parent scroll on touch of child view
v.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:id="@+id/activity_main_parent_scroll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:color/black"
android:focusableInTouchMode="true" >
<LinearLayout
android:id="@+id/activity_main_linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ScrollView
android:id="@+id/activity_main_child_scroll"
android:layout_width="fill_parent"
android:layout_height="@dimen/widthsize100"
android:focusable="true"
android:focusableInTouchMode="true" >
<TextView
android:id="@+id/activity_main_activity_main_text_description"
style="@style/Textview" />
</ScrollView>
<TextView
android:id="@+id/activity_main_activity_main_text_description_3"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_4"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_5"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_6"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_7"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_8"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_9"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_10"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_11"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_12"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_13"
style="@style/Textview"
/>
<TextView
android:id="@+id/activity_main_activity_main_text_description_14"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_15"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_16"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_17"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_18"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_19"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_20"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_21"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_22"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_23"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_24"
style="@style/Textview" />
<TextView
android:id="@+id/activity_main_activity_main_text_description_25"
style="@style/Textview" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
style.xml
<style name="Textview">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:scrollbars">vertical</item>
<item name="android:text">@string/text</item>
<item name="android:textColor">@android:color/white</item>
<item name="android:textSize">@dimen/textsize12</item>
<item name="android:padding">@dimen/padding5</item>
</style>
string.xml
<string name="text">sdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfhsdfdsfhsdjkfhsdkfhsdjkfhsdjkfhsdjfh</string>
dimen.xml
<dimen name="textsize12">12dip</dimen>
<dimen name="padding5">5dip</dimen>
<dimen name="widthsize100">100dp</dimen>
MainActivity.java
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ScrollView;
public class MainActivity extends Activity {
ScrollView mScrollViewParent;
ScrollView mScrollViewChild;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mScrollViewParent=(ScrollView)findViewById(R.id.activity_main_parent_scroll);
mScrollViewChild=(ScrollView)findViewById(R.id.activity_main_child_scroll);
mScrollViewParent.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
Log.v("A","PARENT TOUCH");
// findViewById(R.id.child_scroll).getParent().requestDisallowInterceptTouchEvent(false);
mScrollViewParent.getParent().requestDisallowInterceptTouchEvent(false);
return false;
}
});
mScrollViewChild.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event)
{
Log.v("B","CHILD TOUCH");
// Disallow the touch request for parent scroll on touch of child view
v.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}