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>
  • 相关阅读:
    linux系统调整磁盘分区
    Linux命令sort和uniq 的基本使用
    路由的执行优先级
    Linux命令xargs的使用
    wget命令的使用
    Linux环境下错误码及意义总结
    Linux下使用ip netns命令进行网口的隔离和配置ip地址
    MongoDB初始化创建管理员账户登录
    Python字符串的截取原理,下标的位置图示
    Python操作MongoDB查询时处理ObjectId
  • 原文地址:https://www.cnblogs.com/Oldz/p/14001177.html
Copyright © 2011-2022 走看看