Today's project requires writing a very simple edittext input box, but it requires that when the number of input words is too long, you need to slide up and down to view all text, because there is a "okay" button at the bottom of the page, but at the beginning the problem in the input box cannot slide. I thought from the beginning that this is an event transmission conflict problem, but I tried many methods but couldn't do it. Finally, I tried it one by one to solve it. I won't say much, post the code:
<ScrollView android: android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="10dp" android:minHeight="360dp" android:scrollbars="none"> <EditText android: android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginEnd="10dp" android:layout_marginStart="15dp" android:layout_marginTop="10dp" android:background="@null" android:gravity="top|start" android:hint="@string/FeedBackViewController_Placeholder" android:lineSpacingMultiplier="1.0" android:paddingEnd="10dp" android:paddingStart="10dp" android:maxHeight="450dp" //There was no addition at the beginning, and it also couldn't slide. android:textSize="@dimen/font_size16"/> </ScrollView>
In the code, you need:
(new () { @Override public boolean onTouch(View v, MotionEvent event) { // Solve the problem of nested EditText in scrollView causing it to not slide up and down ().requestDisallowInterceptTouchEvent(true); switch (() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_UP: ().requestDisallowInterceptTouchEvent(false); break; } return false; } });
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.