zoukankan      html  css  js  c++  java
  • Android EditText弹出软键盘实现页面标题头不动,软键盘弹出在编辑框下面

    为了实现EditText编辑的时候弹出软键盘标题头不动,底部编辑框,上移在这总结:

    RelativeLayout在弹出软键盘的时候先寻找android:layout_alignParentBottom属性是否有控件设置为true,如果有将此控件向上移动键盘高度的位置,布局也就位于软键盘的上面,其他控件如果有相对于该控件的位置,也就相对的移动了,如果没有则什么都不做,可以看做布局是一层一层盖上去的,键盘弹出的时候,只把符合要求的当层的布局向上移动,所以如果我们按照这种方法写,肯定是可以的。
    还有一个重点就是,配置文件里面该activity要设置android:windowSoftInputMode=”adjustResize”
    遇到设置之后不生效的结果,那就在布局文件的根布局添加android:fitsSystemWindows=”true”属性。

    <?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:fitsSystemWindows="true"
        tools:context="com.shiwen.oil.activity.NoticeDetailActivity">
    
        <ProgressBar
            android:id="@+id/progressBar"
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_width="match_parent"
            android:layout_height="3dip"
            android:layout_alignParentTop="true"
            android:progressDrawable="@drawable/progressbar_drawable"
            android:visibility="gone"/>
    
        <WebView
            android:id="@+id/webView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@id/progressBar"
            android:layout_weight="1"/>
    
        <RelativeLayout
            android:id="@+id/comment_bottom_ll"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/white"
            android:layout_alignParentBottom="true"
         >
    
            <View
                android:layout_width="match_parent"
                android:layout_height="0.5dp"
                android:background="@color/gray" />
    
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="10dp"
                android:layout_marginTop="10dp"
                android:orientation="horizontal">
    
                <RelativeLayout
                    android:id="@+id/rl"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="13dp"
                    android:layout_weight="3">
    
                    <EditText
                        android:id="@+id/bottom_ed"
                        android:layout_width="match_parent"
                        android:layout_height="32dp"
                        android:background="@drawable/shape_gray_solid_bg"
                        android:hint="写评论"
                        android:minHeight="35dp"
                        android:paddingLeft="20dp"
                        android:paddingRight="5dp"
                        android:textColorHint="@color/gray"
                        android:textSize="14sp" />
                </RelativeLayout>
    
                <Button
                    android:id="@+id/bottom_bnt"
                    android:layout_width="0dp"
                    android:layout_height="32dp"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="10dp"
                    android:layout_toRightOf="@id/rl"
                    android:layout_weight="1"
                    android:background="@drawable/shape_base_bg2"
                    android:text="确认"
                    android:layout_marginRight="5dp"
                    android:textColor="@color/white"
                    android:textSize="13sp" />
    
            </LinearLayout>
        </RelativeLayout>
    
    
    </RelativeLayout>
         <activity
                android:name=".activity.NoticeDetailActivity"
                android:windowSoftInputMode="adjustResize"
                ></activity>
    

     效果图

  • 相关阅读:
    C#制作自定义安装程序
    (转)Linq DataTable的修改和查询
    (转)将rdlc报表作为资源嵌套使用
    C# 中的委托和事件(2)
    C# 中的委托和事件(1)
    C# 自定义控件入门
    Spring中自动装配(转)
    从程序员到CTO的Java技术路线图 (转自安卓巴士)
    spring四种依赖注入方式
    MyEclipse提示键配置、提示快捷键、提示背景色、关键字颜色、代码显示、编...
  • 原文地址:https://www.cnblogs.com/loaderman/p/9582724.html
Copyright © 2011-2022 走看看