In my application i am using EditText to write the Mail description and i made it as per following. My edittext has multiple lines. When i am entering more lines and try to move from bottom to up in edittext at that time scrolling of edittext is not working.
Can anybody 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>
fillViewport allows scrollView to extend it's height equals to the full height of device screen's height in the cases when the child of scroll view has less height.
In Android, a ScrollView is a view group that is used to make vertically scrollable views. A scroll view contains a single direct child only. In order to place multiple views in the scroll view, one needs to make a view group(like LinearLayout) as a direct child and then we can define many views inside it.
Android EditText not editable but scrollableUse this porperties in your EdittText: android:enabled="true" android:focusableInTouchMode="false" android:scrollbars="vertical". Your EditText will be enable, but not focusable for edit. Then, you will able to scroll (in vertical on this case) and will not able to edit.
A ListView in Android is a scrollable list used to display items.
Try this
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 put scrollable control (for example ListView) in ScrollView. And I think it does not work with scrollable EditText into ScrollView.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With