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>
    

     效果图

  • 相关阅读:
    Delphi 之Copyrect的使用
    Delphi GDI对象之脱屏位图(Offscreen Bitmaps),也叫内存位图
    1067. Sort with Swap(0,*) (25)【贪心】——PAT (Advanced Level) Practise
    Server Tomcat v7.0 Server at localhost was unable to start within 45 seconds
    每一个JavaScript开发者都应该知道的10道面试题
    【HDOJ 5407】 CRB and Candies (大犇推导
    Wireshark默认不抓取本地包的解决方式
    Android LaunchMode案例篇
    使用ViewPager实现广告滑动效果
    剑指offer面试题26-复杂链表的复制
  • 原文地址:https://www.cnblogs.com/loaderman/p/9582724.html
Copyright © 2011-2022 走看看