用ScrollView解决弹出软键盘顶出布局问题

来一支蓝立群 2016-12-12 03:52:39
最近遇到在EditText中修改文字时,软键盘弹出来上面的标题栏就给顶没了。百思的不得骑姐。
在Activity中设置了android:windowSoftInputMode="adjustPan",但是这样的话不显示EditText焦点了,整体都不动了。也不可行。
后来百度了下,说用ScrollView来解决,格式<ScrollView><EditText/></ScrollView>,但是我这样配置了还是不行,android:windowSoftInputMode="adjustResize|stateHidden"也配置了。下面是我的xml,大神给看下哪里的问题,是不是需要在.java中配置下?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:fitsSystemWindows="true"
tools:context="com.thocr.camera.ShowResultActivity" >

<RelativeLayout
android:id="@+id/title_RelativeLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/title_bottom_color" >

<com.thocr.view.Back_CustomButton
android:id="@+id/back_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/title_bottom_color"
android:src="@drawable/image_processing_back" />

<TextView
android:id="@+id/title_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/ocr_result"
android:textColor="@android:color/white"
android:textSize="18sp" />
</RelativeLayout>

<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/ocr_done_btn"
android:layout_below="@+id/title_RelativeLayout"
android:background="@android:color/black"
android:fillViewport="true" >

<LinearLayout
android:id="@+id/LinearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<ImageView
android:id="@+id/image_show_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<EditText
android:id="@+id/show_result"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:textColor="@color/setting_text_color" />
</LinearLayout>
</ScrollView>

<ImageView
android:id="@+id/ocr_done_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="@drawable/ocr_done_btn" />

</RelativeLayout>
...全文
1070 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
mkklsg 2017-02-23
  • 打赏
  • 举报
回复
有没有试过当设置android:scrollbars="none"这个属性时候,toolbar还会不会被顶出?我也是用scrollview解决这个问题,但是设置没有滚动条时候,问题又回来了,求解决
来一支蓝立群 2016-12-22
  • 打赏
  • 举报
回复
已经解决,在Activity中去掉全屏属性设置就可以了。this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);这个去掉
qq_36330936 2016-12-14
  • 打赏
  • 举报
回复
怎么会顶没了呢
来一支蓝立群 2016-12-13
  • 打赏
  • 举报
回复
不要沉啊
qq_17059165 2016-12-12
  • 打赏
  • 举报
回复
真的很不错,根据你的方法解决了我的问题

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧