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>
  • 相关阅读:
    Android硬件访问服务中的HAL-查看打印的信息
    JAVA程序通过JNI调用C/C++库
    How to install android studio on ubuntu14.04
    Android驱动-Java入门学习(java安装)
    ubuntu系统64位dnw
    ubuntu安装nfs服务
    人脸识别--SeetaFace
    在Ubuntu14.04下配置Samba 完成linux和windows之间的文件共享
    Android驱动学习-Eclipse安装与配置
    unsupported major.minor version
  • 原文地址:https://www.cnblogs.com/Oldz/p/14001177.html
Copyright © 2011-2022 走看看