How to get scroll in edittext when it is inside scrollview?

In my application, I use EditText to write a description of Mail, and I made it as follows. My edittext has several lines. When I enter more lines and try to move from bottom to top in edittext, then the edittext scroll does not work.

Can someone help me? Thanks..

<ScrollView android:id="@+id/scrollView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:scrollbarStyle="insideOverlay"> <EditText android:id="@+id/edBody" android:layout_width="fill_parent" android:layout_height="wrap_content" android:lines="5" android:scrollbars="vertical" android:text="" android:inputType="textMultiLine"/> </ScrollView> 
+7
source share
3 answers

try it

main.xml

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <EditText android:layout_width="100dp" android:layout_height="100dp" android:text="Loooooooooonng loooooooooong teeeeeeeeeeext" android:id="@+id/et" android:maxLines = "100" android:scrollbars = "vertical" /> </LinearLayout> 

MyActivity.java

 public class MyActivity extends Activity { private EditText et; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); et= (EditText) findViewById(R.id.et); et.setMovementMethod(new ScrollingMovementMethod()); } } 

NOTE. You cannot set a scrollable control (e.g. ListView) in a ScrollView. And I think this does not work with scrollable EditText in ScrollView.

+1
source

try this hope that it can work

 EditText et=(EditText)findViewById(R.id.edbody); et.setMovementMethod(new ScrollingMovementMethod()); 

in your activity

0
source

First create your id for your scroll and then write this code in your method.

 et.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { mScrollMain.requestDisallowInterceptTouchEvent(true); return false; } }); 

cahnge Listen to mScrollMain with a scrollview object. they work definitely

0
source

All Articles