Android:编辑文本消失
当软键盘出现在 adjustResize 模式时,我的编辑文本消失。有相对布局,自定义视图在孔屏幕尺寸上拉伸作为背景,上面有很少的编辑文本。在 adjustPan 模式下,一切正常,但您看不到键盘后面的编辑文本。所有布局设置都是硬编码的,没有 xml。如果我在没有背景视图的情况下构建它,则一切正常。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<com.mypkg.Panel android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="@+id/panel"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"></com.mypkg.Panel>
<EditText android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="@+id/edit1"
android:layout_alignParentBottom="true" android:layout_marginBottom="23dp"
android:layout_alignParentRight="true" android:layout_alignParentLeft="true">
</EditText>
</RelativeLayout>
class Panel extends SurfaceView implements SurfaceHolder.Callback {...
When soft keyboard appears in adjustResize mode, my edittext disappears. There is relativelayout with custom view stretched on the hole screen size as background and few edittexts over it. In adjustPan mode all works fine but you can't see editetext behind keyboard. All layout settings are hardcoded, there no xml. If i build it without background view all works fine.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<com.mypkg.Panel android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="@+id/panel"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"></com.mypkg.Panel>
<EditText android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="@+id/edit1"
android:layout_alignParentBottom="true" android:layout_marginBottom="23dp"
android:layout_alignParentRight="true" android:layout_alignParentLeft="true">
</EditText>
</RelativeLayout>
class Panel extends SurfaceView implements SurfaceHolder.Callback {...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将整个布局放在
ScrollView
中。使用 ScrollView,您的布局将向上滚动,或者在启用软键盘后能够向上滚动(取决于设备)。[编辑]
本文下面的评论摘要:按照 本文档。
[/编辑]
Put your whole layout within a
ScrollView
. With a ScrollView your Layout will be scrolled up or is able to scroll up (depending on the device) once the soft keyboard is enabled.[Edit]
Summary of the comments below this post: Use the layout folders for ldpi, mdpi and hdpi as proposed by this documentation.
[/Edit]
将此行添加到您的 AndroidManifest.xml 中。为我工作! :)
Add this line to your AndroidManifest.xml. Worked for me! :)