android – 对话框片段中软键盘后面的Autocompletetextview下拉列表

前端之家收集整理的这篇文章主要介绍了android – 对话框片段中软键盘后面的Autocompletetextview下拉列表前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我的应用程序中有一个对话框片段,其中包含autocompletetextview,但下拉列表不是与软键盘的顶部对齐,而是放在后面,不提供对某些项目的访问权限.

这是布局:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_width="match_parent"
  4. android:layout_height="wrap_content"
  5. android:gravity="center"
  6. android:padding="10dp"
  7. android:orientation="horizontal"
  8. android:windowSoftInputMode="adjustPan|adjustResize">
  9.  
  10. <android.widget.AutoCompleteTextView
  11. android:layout_width="0dp"
  12. android:layout_height="wrap_content"
  13. android:id="@+id/customDialogAtocompleteTextview"
  14. android:layout_weight=".7"
  15. android:layout_gravity="top" />
  16.  
  17. <LinearLayout
  18. android:orientation="vertical"
  19. android:layout_width="0dp"
  20. android:layout_height="wrap_content"
  21. android:layout_weight=".3">
  22. <Button
  23. android:id="@+id/customDialogBtOk"
  24. android:layout_width="match_parent"
  25. android:layout_height="wrap_content"
  26. android:text="Aceptar"/>
  27. <Button
  28. android:id="@+id/customDialogBtSearch"
  29. android:layout_width="match_parent"
  30. android:layout_height="wrap_content"
  31. android:text="Buscar"/>
  32. <Button
  33. android:id="@+id/customDialogBtMore"
  34. android:layout_width="match_parent"
  35. android:layout_height="wrap_content"
  36. android:text="Mas"/>
  37. </LinearLayout>
  38.  
  39. </LinearLayout>

那我怎么能让它与键盘对齐?

解决方法

理论上说android:windowSoftInputMode =“adjustPan | adjustResize”应该这样做,但由于某些原因它没有,所以你必须以编程方式做同样的事情:
  1. getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

Aaaaa和魔法发生了

猜你在找的Android相关文章