EditText 上的键盘重叠问题,adjustpan 不起作用
Keyboard overlapping issue on EditText with adjustpan not working
我正在使用这段代码,但键盘仍然与 EditText 重叠。可以做什么
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeContainer"
android:layout_below="@+id/optionsBar"
android:layout_above="@+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animationCache="false"
android:divider="@null"
android:scrollbars="none"
android:overScrollMode="never"
android:dividerHeight="0dp"
android:listSelector="#00000000"
android:fadingEdge="none"
android:scrollingCache="false"
/>
</android.support.v4.widget.SwipeRefreshLayout>
<RelativeLayout
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="@+id/bottomBar"
android:background="@drawable/top_bar_bg"
>
<EditText
android:layout_width="match_parent"
android:layout_height="30dp"
android:inputType="text"
android:paddingLeft="10dp"
android:paddingRight="43dp"
android:layout_marginRight="5dp"
android:layout_centerVertical="true"
android:maxLines="1"
android:hint="Your Message"
android:textColorHint="@android:color/white"
android:layout_marginLeft="5dp"
android:textColor="@android:color/white"
android:textSize="12sp"
android:id="@+id/chatBox"
android:background="@drawable/message_type_area"
/>
<Button
android:gravity="center"
android:layout_height="23dp"
android:layout_width="37dp"
android:contentDescription="@null"
android:background="@drawable/send_btn"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:id="@+id/sendBtn"/>
</RelativeLayout>
</RelativeLayout>
<activity
android:name=".ChatActivity"
android:windowSoftInputMode="adjustPan"
android:screenOrientation="portrait" >
</activity>
全屏禁用软输入调整模式。参见:
Android How to adjust layout in Full Screen Mode when softkeyboard is visible
https://issues.apache.org/jira/browse/CB-4404
https://groups.google.com/forum/#!msg/android-developers/T193nVgXDSA/O6UZmDqskFYJ
adjustResize
在您使用 FullScreenActivity 时无法工作。一种解决方案是将整个布局包含在 ScrollView 中,并在 editText 获得焦点时将其滚动到位置 editText.getY() + editText.getMeasuredHeight()
。
或者,如果您想快速解决问题,请查看 this solution 此处的类似问题。
属性 android:windowSoftInputMode="adjustResize" 不适用于全屏 activity,您必须删除 activity 全屏标志才能利用调整调整大小。
看这个:全屏 window 将忽略 window 的 softInputMode 字段的值 SOFT_INPUT_ADJUST_RESIZE; window 将保持全屏并且不会调整大小。
android:maxLines="1" 在您的 xml 文件中并在 mainfiest 文件中使用。
<activity
android:name="Logintab"
android:windowSoftInputMode="adjustPan"
android:label="@string/app_name"></activity>
我正在使用这段代码,但键盘仍然与 EditText 重叠。可以做什么
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeContainer"
android:layout_below="@+id/optionsBar"
android:layout_above="@+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animationCache="false"
android:divider="@null"
android:scrollbars="none"
android:overScrollMode="never"
android:dividerHeight="0dp"
android:listSelector="#00000000"
android:fadingEdge="none"
android:scrollingCache="false"
/>
</android.support.v4.widget.SwipeRefreshLayout>
<RelativeLayout
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="@+id/bottomBar"
android:background="@drawable/top_bar_bg"
>
<EditText
android:layout_width="match_parent"
android:layout_height="30dp"
android:inputType="text"
android:paddingLeft="10dp"
android:paddingRight="43dp"
android:layout_marginRight="5dp"
android:layout_centerVertical="true"
android:maxLines="1"
android:hint="Your Message"
android:textColorHint="@android:color/white"
android:layout_marginLeft="5dp"
android:textColor="@android:color/white"
android:textSize="12sp"
android:id="@+id/chatBox"
android:background="@drawable/message_type_area"
/>
<Button
android:gravity="center"
android:layout_height="23dp"
android:layout_width="37dp"
android:contentDescription="@null"
android:background="@drawable/send_btn"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:id="@+id/sendBtn"/>
</RelativeLayout>
</RelativeLayout>
<activity
android:name=".ChatActivity"
android:windowSoftInputMode="adjustPan"
android:screenOrientation="portrait" >
</activity>
全屏禁用软输入调整模式。参见:
Android How to adjust layout in Full Screen Mode when softkeyboard is visible
https://issues.apache.org/jira/browse/CB-4404
https://groups.google.com/forum/#!msg/android-developers/T193nVgXDSA/O6UZmDqskFYJ
adjustResize
在您使用 FullScreenActivity 时无法工作。一种解决方案是将整个布局包含在 ScrollView 中,并在 editText 获得焦点时将其滚动到位置 editText.getY() + editText.getMeasuredHeight()
。
或者,如果您想快速解决问题,请查看 this solution 此处的类似问题。
属性 android:windowSoftInputMode="adjustResize" 不适用于全屏 activity,您必须删除 activity 全屏标志才能利用调整调整大小。
看这个:全屏 window 将忽略 window 的 softInputMode 字段的值 SOFT_INPUT_ADJUST_RESIZE; window 将保持全屏并且不会调整大小。
android:maxLines="1" 在您的 xml 文件中并在 mainfiest 文件中使用。
<activity
android:name="Logintab"
android:windowSoftInputMode="adjustPan"
android:label="@string/app_name"></activity>