Mam nieprzyjemny problem. Mam EditText
(8 linii) wewnątrz ScrollView
. A gdy próbuję przewinąć tekst w pliku EditText
, jego zachowanie nie jest stabilne. Czasami jest przewijany, czasami nie jest skupiony.Przewijanie EditText wewnątrz ScrollView
To jest mój plik układ, aby moje pytanie bardziej jasne:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp" >
<TextView
android:id="@+id/wo_task_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/no_description" />
<TextView
android:id="@+id/wo_task_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/no_description" />
<TextView
android:id="@+id/wo_task_comments_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/comments" />
<Button
android:id="@+id/wo_task_select_comment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/select_comment_from_template" />
<EditText
android:id="@+id/wo_task_comments"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="top|left"
android:hint="@string/enter_your_comment_here"
android:lines="8"
android:maxLines="10"
android:minLines="6"
android:scrollbars="vertical"
android:singleLine="false" />
</LinearLayout>
Rozumiem, że mam ten problem z powodu posiadania jednej przewijalną kontrolę wewnątrz drugiego, ale nie wiem, co z tym zrobić. Więc proszę, pomóż mi, jeśli możesz.
Z góry dziękuję.
public void initComments(final View view) {
EditText comment = (EditText) view.findViewById(R.id.wo_task_comments);
comment.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(final View v, final 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;
}
});
comment.setText(currentTask.getComment() + "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");
}
Próbowałem tego, i bez rezultatu. Nadal nie mogę przewinąć mojego pola edycji.
właśnie zaksięgowania samą odpowiedź, jako dodatek być może trzeba wyłączyć inne przewijanie otherviews.setOnTouchListener (nowa OnTouchListener() { \t \t \t public onolean boolean (Zobacz v, zdarzenie MotionEvent) { \t \t \t \t return true; \t \t \t} \t \t}); – Ceetn
dzięki za odpowiedź. W tej chwili wciąż nie jestem w stanie rozwiązać mojego problemu. – Orest
Zaktualizowałem moje pytanie. – Orest