I have a ScrollView
inside which is an EditText
which is set to scroll vertically. But it does not scrolls. Instead the whole layout scrolls, Whene
Use this Code Its Working
in Xml
android:singleLine="false"
android:overScrollMode="always"
android:scrollbarStyle="insideInset"
android:scrollbars="vertical"
in Pragraming
et_feedback.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View view, MotionEvent event) {
if (view.getId() == R.id.et_feedback) {
view.getParent().requestDisallowInterceptTouchEvent(true);
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_UP:
view.getParent().requestDisallowInterceptTouchEvent(false);
break;
}
}
return false;
}
});
noteEdit.setMovementMethod(new ScrollingMovementMethod());
ScrollingMovementMethod.getInstance();
noteEdit.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
noteEdit.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});
ScrollView
as your parent most layout. That's reason
your whole layout gets scrolled.android:scrollbars = "vertical"
which means if the EditText
grows a vertical srollBar will appear. You will get the scrollbar and scrolling effect
only if edittext has data high enough..Hope this helps...
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
This will make your entire layout scrollable.
For setting your edittext scrollable add android:scrollbars="vertical"
to your edittext
In your code its already written
<EditText
android:id="@+id/newTodoText"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:minLines="2"
android:maxLines="7"
android:hint="Write something"
android:scrollbars = "vertical" >
Remove the from code.It will work fine
you should use NestedScrollView class. This class support child scrolling inside parent scrolling. This class can be a child or a parent.
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#d6d8d9">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="512"
android:text=" your content"/>
<android.support.v4.widget.NestedScrollView
android:layout_below="@id/ll_button"
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#d6d8d9">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="your content"
android:maxLines="512"/>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>