输入法出现时,局部上移的代码
其实读了一篇Android实现弹出输入法时,顶部固定,中间部分上移的效果文章之后,大致方法已经知道,可是怎么调都调不对,因此笔者试了各种方法,最后才发现由于一个小细节才没有局部上移的效果。
具体步骤如下:
(1)在AndroidManifest.xml中配置的activity标签里添加android:windowSoftInputMode="stateAlwaysHidden|adjustResize"属性,stateAlwaysHidden可以不加,adjustResize一定要加。
(2)如果activity是全屏,请去掉全屏属性,否则无法有此效果。笔者就是在这一步中招了,由于个人习惯,喜欢设置全屏的activity,所以导致无法完成局部上移的效果。
(3)最后,布局文件如下:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<!-- 固定布局 fillViewport表示子布局填充满-->
</ScrollView>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentBottom="true">
<EditText
android:id="@+id/edittext"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
</RelativeLayout> 相关推荐
yonggeno 2020-08-02
etzt 2020-05-31
86206132 2020-04-09
81296031 2020-04-08
xinlugang 2020-02-29
kanpiaoxue 2020-01-29
89236831 2020-01-04
TinyDolphin 2019-11-29
81224450 2019-11-19
海绵宝宝的欧尼 2015-04-19
ThedakeLaugh 2010-11-02
酷云的csdn 2019-11-05
Chrome浏览器一下载就崩溃的解决方法。环境操作系统:win10浏览器:chrome输入法: 酷狗问题描述:一下载chrome就崩溃。解决办法先切换输入法,可以换成win10自带数据法,然后点击下载
mixley 2019-11-05
micmouse 2019-10-14
chenzelin 2016-12-03
yinsui 2011-09-18