Android:软键盘推送整个布局,需要调整listview的大小

前端之家收集整理的这篇文章主要介绍了Android:软键盘推送整个布局,需要调整listview的大小前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个全屏聊天布局,我在顶部有一个带有徽标的标题,然后是一个包含所有聊天消息的listView,在底部我有editText和buttom来发送聊天消息.现在当我点击editText时会发生什么,整个布局被推高了.我需要的是,带有徽标的标题始终保持原样,并且listView可以调整大小.

这不是诀窍:

  1. android:windowSoftInputMode="adjustResize"

这两个:

  1. android:windowSoftInputMode="adjustPan"

也许是因为我有全屏布局?

我需要找到一种不同的方法来调整我的listView一旦键盘存在,任何想法?提前致谢!

这是我的布局

  1. <LinearLayout
  2.  
  3. android:layout_width="match_parent"
  4. android:layout_height="70dp"
  5. android:background="@drawable/ss99_yellow_area_navigation_bar"
  6. android:baselineAligned="false"
  7. android:orientation="horizontal" >
  8.  
  9. <ImageView
  10. android:id="@+id/back"
  11. android:layout_width="45dp"
  12. android:layout_height="match_parent"
  13. android:layout_marginBottom="10dp"
  14. android:layout_marginLeft="5dp"
  15. android:layout_marginTop="5dp"
  16. android:adjustViewBounds="true"
  17. android:clickable="true"
  18. android:src="@drawable/ss99_button_back" />
  19.  
  20. <ImageView
  21. android:id="@+id/logo"
  22. android:layout_width="wrap_content"
  23. android:layout_height="75dp"
  24. android:layout_weight="1"
  25. android:adjustViewBounds="true"
  26. android:src="@drawable/ss99_logo_small" />
  27.  
  28. </LinearLayout>
  29.  
  30. <RelativeLayout
  31. android:layout_width="match_parent"
  32. android:layout_height="45dp"
  33. android:layout_marginTop="-2dp"
  34. android:background="@drawable/ss9_yellow_bar_chat_new" >
  35.  
  36. <TextView
  37. android:id="@+id/userOpponent"
  38. android:layout_width="wrap_content"
  39. android:layout_height="wrap_content"
  40. android:layout_alignParentLeft="true"
  41. android:layout_centerVertical="true"
  42. android:layout_marginLeft="5dp"
  43. android:text="Medium Text"
  44. android:textAppearance="?android:attr/textAppearanceMedium" />
  45.  
  46. <TextView
  47. android:id="@+id/userUser"
  48. android:layout_width="wrap_content"
  49. android:layout_height="wrap_content"
  50. android:layout_alignBaseline="@+id/userOpponent"
  51. android:layout_alignBottom="@+id/userOpponent"
  52. android:layout_alignParentRight="true"
  53. android:layout_marginRight="5dp"
  54. android:text="Medium Text"
  55. android:textAppearance="?android:attr/textAppearanceMedium" />
  56.  
  57. </RelativeLayout>
  58.  
  59. <ListView
  60. android:id="@+id/chatList"
  61. android:layout_width="fill_parent"
  62. android:layout_height="wrap_content"
  63. android:cacheColorHint="#00000000"
  64. android:divider="#00000000"
  65. android:listSelector="#00000000"
  66. android:layout_weight="1"
  67. android:stackFromBottom="true"
  68. android:transcriptMode="alwaysScroll">
  69. </ListView>
  70.  
  71. <RelativeLayout
  72. android:layout_width="match_parent"
  73. android:layout_height="60dp"
  74. android:background="@drawable/ss9_yellow_area_for_bottom_and_chat_string" >
  75.  
  76. <ImageView
  77. android:id="@+id/field1"
  78. android:layout_width="220dp"
  79. android:layout_height="wrap_content"
  80. android:layout_alignParentLeft="true"
  81. android:layout_alignParentTop="true"
  82. android:layout_gravity="center"
  83. android:layout_marginLeft="20dp"
  84. android:layout_marginTop="10dp"
  85. android:adjustViewBounds="true"
  86. android:scaleType="centerInside"
  87. android:src="@drawable/ss1_field_big" />
  88.  
  89. <EditText
  90. android:id="@+id/chatEdit"
  91. android:layout_width="200dp"
  92. android:layout_height="wrap_content"
  93. android:layout_alignBottom="@+id/field1"
  94. android:layout_alignLeft="@+id/field1"
  95. android:layout_alignTop="@+id/field1"
  96. android:layout_marginBottom="3dp"
  97. android:layout_marginLeft="10dp"
  98. android:layout_marginTop="1dp"
  99. android:background="@null"
  100. android:inputType="textAutoCorrect|textAutoComplete"
  101. android:textAppearance="?android:attr/textAppearanceMedium" >
  102.  
  103. </EditText>
  104.  
  105. <ImageView
  106. android:id="@+id/chatOk"
  107. android:layout_width="60dp"
  108. android:layout_height="60dp"
  109. android:layout_alignParentRight="true"
  110. android:layout_alignParentTop="true"
  111. android:layout_marginBottom="5dp"
  112. android:adjustViewBounds="false"
  113. android:baselineAlignBottom="false"
  114. android:clickable="true"
  115. android:cropToPadding="false"
  116. android:scaleType="fitEnd"
  117. android:src="@drawable/ss4_button_go_small" />
  118.  
  119. </RelativeLayout>
  120.  
  121. </LinearLayout>

解决方法

尝试将此添加到Manifest.xml中的活动
  1. <activity
  2. android:windowSoftInputMode="stateVisible|adjustNothing">
  3. </activity>

猜你在找的Android相关文章