Scrollen EditText innen ScrollView
Ich habe ein unangenehmes problem. Ich habe EditText
(8 Linien) im inneren ScrollView
. Und wenn ich versuche zu scrollen, text in EditText
Verhalten ist nicht stabil. Manchmal ist es scrollen, manchmal ist es nicht die Einnahme konzentrieren.
Dies ist mein layout-Datei, damit meine Frage deutlicher:
<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>
Ich verstehe, dass ich diese Frage, weil der mit einem Scrollbar-Steuerelement innerhalb eines anderen, doch ich weiß nicht, was mit diesem zu tun. Also, bitte helfen Sie mir, wenn Sie können.
Vielen Dank im Voraus.
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");
}
Ich hab das versucht und kein Ergebnis. Ich bin immer noch nicht scrollen meine editbox.
Du musst angemeldet sein, um einen Kommentar abzugeben.
Versuchen:
In Ihrem Fall:
}
Shilkin code funktioniert Super.Ich mache es ein wenig stärker.Jetzt ist es mit der situation umgehen, dass der EditText ist die direkte Muttergesellschaft ist nicht der ScrollView(z.B. EditText ist verpackt in LinearLayout, bevor es in die scrollview).
Die Methode nicht code:
Nennen mag:
Ist eine Option, um die Größe des Kindes
EditText
als die Höhe der gesamten max-Linien (max_lines * font_height). So, das interne scrollen wird ausgeschaltet, und die nur einen Bildlauf der Eltern-Blättern.