zoukankan      html  css  js  c++  java
  • Android输入框软键盘间距

    https://blog.csdn.net/m0_37388625/article/details/106025262

    纯笔记,无任何高科技,为了软键盘弹出时与输入框保持一点点的距离,使用ScrollView+LinearLayout包裹住输入框,ScrollView+LinearLayout的高度稍微比输入框高一点即可(无需java代码控制),效果如下图:

    <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity">
    
        <ScrollView
            android:layout_gravity="bottom"
            android:layout_width="match_parent"
            android:padding="5dp"
            android:background="@color/colorPrimaryDark"
            android:layout_height="60dp">
    
            <LinearLayout
                android:orientation="horizontal"
                android:layout_width="match_parent"
                android:layout_height="match_parent">
    
                <Button
                    android:text="Click"
                    android:layout_width="100dp"
                    android:layout_height="match_parent" />
    
                <LinearLayout
                    android:id="@+id/line_comment"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="bottom"
                    android:background="#f00"
                    android:focusable="true"
                    android:visibility="visible"
                    android:focusableInTouchMode="true"
                    android:gravity="center_vertical"
                    android:orientation="vertical">
                    <EditText
                        android:id="@+id/etComment"
                        android:layout_width="match_parent"
                        android:layout_height="40dp"
                        android:layout_marginLeft="12dp"
                        android:layout_marginTop="8dp"
                        android:layout_marginBottom="8dp"
                        android:layout_weight="1"
                        android:inputType="text"
                        android:background="#0f0"
                        android:hint="输入框hint..."
                        android:layout_marginRight="12dp"
                        android:imeOptions="actionSend"
                        android:maxLength="100"
                        android:paddingLeft="12dp"
                        android:textSize="16sp" />
    
                    <View
                        android:id="@+id/viewKeyboard"
                        android:background="#00f"
                        android:layout_width="match_parent"
                        android:layout_height="0dp" />
                </LinearLayout>
            </LinearLayout>
        </ScrollView>
    </FrameLayout>
  • 相关阅读:
    PHP数组的几个操作,求并集,交集,差集,数组与字符串的相互转换及数组去重
    文件系统添加链接
    HTML中插入视频
    magento模块的建立
    数组函数
    字符串函数
    阿里服务器用户的添加
    ViewChild
    GitHub 图片加载不出来怎么办
    常用正则表达式
  • 原文地址:https://www.cnblogs.com/Oldz/p/14001177.html
Copyright © 2011-2022 走看看