zoukankan      html  css  js  c++  java
  • 输入法出现时,中间固定,底部上移的代码

      读了一篇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的子布局期盼是使用具体高度,尽量不用matchparent属性->

    </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>
  • 相关阅读:
    AVR单片机教程——PWM调光
    AVR单片机教程——蜂鸣器
    AVR单片机教程——串口接收
    做个别出心裁的圣诞礼物
    电源选择电路的原理
    AVR单片机教程——串口发送
    C++类成员默认初始值
    AVR单片机教程——旋转编码器
    10.Django-form表单
    09.Django-数据库优化
  • 原文地址:https://www.cnblogs.com/jlyg/p/6594768.html
Copyright © 2011-2022 走看看