• 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>
  • 相关阅读:
    HDU 5492 Find a path
    codeforce gym 100548H The Problem to Make You Happy
    Topcoder SRM 144 Lottery
    codeforce 165E Compatible Numbers
    codeforce gym 100307H Hack Protection
    区间DP总结
    UESTC 1321 柱爷的恋爱 (区间DP)
    HDU 4283 You Are the One (区间DP)
    HDU 2476 String painter (区间DP)
    UESTC 426 Food Delivery (区间DP)
  • 原文地址:https://www.cnblogs.com/Oldz/p/14001177.html
Copyright © 2020-2023  润新知