android – 在ScrollView中的EditText中滚动

前端之家收集整理的这篇文章主要介绍了android – 在ScrollView中的EditText中滚动前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
参见英文答案 > android: ViewPager and HorizontalScrollVIew11
是否可以滚动到ScrollView中的EditText?
  1. <ScrollView
  2. android:layout_width="fill_parent"
  3. android:layout_height="wrap_content">
  4. <LinearLayout
  5. android:layout_width="fill_parent"
  6. android:layout_height="wrap_content"
  7. android:orientation="vertical">
  8. <!-- scroll inside this EditText -->
  9. <EditText android:id="@+id/et_scrollhere"
  10. android:lines="6"
  11. android:layout_width="fill_parent"
  12. android:layout_height="wrap_content"
  13. android:hint="Voorbeeld"
  14. android:layout_margin="5dp"
  15. android:scrollbars="vertical"
  16. android:inputType="textMultiLine"/>
  17. </LinearLayout>
  18. </ScrollView>

或者是否可以在纵向模式下将EditText嵌入到键盘中?像WhatsApp,EditText是可滚动的.

解决方法

  1. EditText dwEdit = (EditText) findViewById(R.id.DwEdit);
  2. dwEdit.setOnTouchListener(new OnTouchListener() {
  3.  
  4. public boolean onTouch(View view,MotionEvent event) {
  5. // TODO Auto-generated method stub
  6. if (view.getId() ==R.id.DwEdit) {
  7. view.getParent().requestDisallowInterceptTouchEvent(true);
  8. switch (event.getAction()&MotionEvent.ACTION_MASK){
  9. case MotionEvent.ACTION_UP:
  10. view.getParent().requestDisallowInterceptTouchEvent(false);
  11. break;
  12. }
  13. }
  14. return false;
  15. }
  16. });

并在你的xml文件

  1. <EditText
  2. android:id="@+id/DwEdit"
  3. android:layout_width="fill_parent"
  4. android:layout_height="wrap_content"
  5. android:minLines="10"
  6. android:scrollbarStyle="insideInset"
  7. android:scrollbars="vertical"
  8. android:overScrollMode="always"
  9. android:inputType="textCapSentences">
  10. </EditText>

我希望它能帮助你..

猜你在找的Android相关文章