How to scroll the edittext inside the scrollview
Try this..
Add below lines into your EditText
android:overScrollMode="always"
android:scrollbarStyle="insideInset"
android:scrollbars="vertical"
Example
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginTop="15dp"
android:background="#eeeeee"
android:inputType="textMultiLine"
android:singleLine="false"
android:overScrollMode="always"
android:scrollbarStyle="insideInset"
android:scrollbars="vertical"
android:text="Android applications normally run entirely on a single thread by default the “UI thread” or the “main thread”.
android:textAppearance="?android:attr/textAppearanceMedium" >
</EditText>
EDIT
Programmatically
youredittext.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (youredittext.hasFocus()) {
v.getParent().requestDisallowInterceptTouchEvent(true);
switch (event.getAction() & MotionEvent.ACTION_MASK){
case MotionEvent.ACTION_SCROLL:
v.getParent().requestDisallowInterceptTouchEvent(false);
return true;
}
}
return false;
}
});
Scrolling EditText inside ScrollView
Try:
@Override
public void onCreate(Bundle savedInstanceState) {
.....
EditText et = (EditText)findViewById(R.id.wo_task_comments);
et.setOnTouchListener(this);
.....
}
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if(view.getId() == R.id.wo_task_comments){
view.getParent().requestDisallowInterceptTouchEvent(true);
switch (motionEvent.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_UP:
view.getParent().requestDisallowInterceptTouchEvent(false);
break;
}
}
return false;
}
In your case:
public class MyActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
initComments(findViewById(R.id.YOUR_MAIN_LAYOUT_ID));
}
public void initComments(final View view) {
EditText comment = (EditText) view.findViewById(R.id.wo_task_comments);
comment.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(final View v, final MotionEvent motionEvent) {
if (v.getId() == R.id.wo_task_comments) {
v.getParent().requestDisallowInterceptTouchEvent(true);
switch (motionEvent.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_UP:
v.getParent().requestDisallowInterceptTouchEvent(
false);
break;
}
}
return false;
}
});
comment.setText("very very long comment"
+ "very very long comment\n" + "very very long comment\n"
+ "very very long comment\n" + "very very long comment\n"
+ "very very long comment\n" + "very very long comment\n"
+ "very very long comment\n" + "very very long comment\n"
+ "very very long comment\n" + "very very long comment\n"
+ "very very long comment\n" + "very very long comment\n"
+ "very very long comment\n" + "very very long comment\n"
+ "very very long comment\n" + "very very long comment\n"
+ "very very long comment");
}
}
Edit text inside scroll view is not scrollable
You can perform this to make an edittext scrollable:
EditText EtOne = (EditText) findViewById(R.id.comment1);
EtOne.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (v.getId() == R.id.comment1) {
v.getParent().requestDisallowInterceptTouchEvent(true);
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_UP:
v.getParent().requestDisallowInterceptTouchEvent(false);
break;
}
}
return false;
}
});
See "Scrolling editbox inside scrollview"
EditText not scrollable inside NestedScrollView
The answer is actually simpler than I thought.
After pasting your xml (and making the necessary changes for it to build - missing dimens. etc...) I just changed the height of your EditText
to wrap_content
and the bug was gone.
The answer lies here:
Comparing the measurements of the EditText
at different points in time, on the left with height=match_parent
and on the right with height=wrap_content
On the left:
The EditText
is drawn on screen empty with a certain size, you paste the text and it's size doesn't change. Showing/Hiding the keyboard is one important event in the life of a screen, it's called a configuration change this causes elements to be measured again and re-drawn.
On the right:
If you change the height of the EditText
to wrap_content
it will force a measure and re-draw immediately after insertion.
Hope this helps :)
Edittext is not scrollable in scrollview
refer link.
EditText EtOne = (EditText) findViewById(R.id.EditText01);
EtOne.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (v.getId() == R.id.comment1) {
v.getParent().requestDisallowInterceptTouchEvent(true);
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_UP:
v.getParent().requestDisallowInterceptTouchEvent(false);
break;
}
}
return false;
}
});
Related Topics
How to Load a Image from Assets
Align Top of Image to Top of Textview
Why Can't One Add/Remove Items from an Arrayadapter
How to Programmatically Uninstall a Package in Android
Failure [Install_Failed_Older_Sdk] Android-L
Android Studio Where to Install Ndk File? (Downloaded It in Zip)
How to Implement Google Maps Search by Address in Android
How to Use Sms Content Provider? Where Are the Docs
Android Layout Animations from Bottom to Top and Top to Bottom on Imageview Click
Download and Extract Zip File in Android
Determine Angle of View of Smartphone Camera
View Binding - How to Get a Binding for Included Layouts
Android Studio Image Asset Launcher Icon Background Color
Loading an Android Resource into a Webview
Save Internal File in My Own Internal Folder in Android
Android Opening a File with Action_Get_Content Results into Different Uri'S