Android 设置输入法[软键盘]将底部布局推上去

效果
在这里插入图片描述

说明:
1适用范围Android 6.0(23)及以上,Android 5.0标题栏不太适配,看注释
2.也可以使用popwindow来实现,晚上很多例子了

操作如下
1.设置Manifest中Activtiy的theme属性如下:

<activity android:name=".ui.CommentsActivity"
            android:theme="@style/search_edit"
            >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

2.style中search_edit内容如下:

<style name="search_edit" parent="Theme.AppCompat.Light.NoActionBar" >
        <item name="android:windowAnimationStyle">@style/AnimationActivity</item><!-- 页面切换动画 -->
        <item name="android:statusBarColor">@color/colorPrimary</item> <!-- 状态栏背景色 -->
        <item name="android:windowLightStatusBar" tools:ignore="NewApi">true</item> <!-- 状态栏模式 true-黑色文字,白色背景 【6.0以下无效】 -->
    </style>

3.CommentsActivity代码如下

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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">


    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/colorPrimary"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:title="标题" />

    <com.scwang.smart.refresh.layout.SmartRefreshLayout
        android:id="@+id/smartlayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/toolbar"
        android:layout_above="@id/editBox">

        <com.scwang.smart.refresh.header.ClassicsHeader
            android:layout_width="match_parent"
            android:layout_height="100dp" />

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/recyclerView"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

        <com.scwang.smart.refresh.footer.ClassicsFooter
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </com.scwang.smart.refresh.layout.SmartRefreshLayout>

    <LinearLayout
        android:id="@+id/editBox"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:focusableInTouchMode="true"
        android:orientation="vertical"
        android:paddingTop="8dp"
        android:paddingBottom="8dp"
        android:layout_alignParentBottom="true">

        <EditText
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:layout_marginStart="15dp"
            android:layout_marginEnd="15dp"
            android:background="@android:color/holo_green_dark"
            android:paddingLeft="5dp"
            android:paddingRight="5dp"
            android:textSize="13dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="15dp"
            android:layout_marginTop="5dp"
            android:text="0/300"
            android:textColor="#c7c7c7"
            android:textSize="11dp" />
    </LinearLayout>
</RelativeLayout>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值