安卓键盘弹出是底部布局整体上移实现

来源:互联网 发布:网络女主播排行榜2016 编辑:程序博客网 时间:2024/06/06 03:17
两种方案   1  在相关的activity的清单中  加入   android:windowSoftInputMode="adjustResize",  这个无关布局可以实现功能2 ,在不需要配置上面清单文件的情况下,可以使用下面的方案<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:id="@+id/activity_main"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context="com.founder.demo.MainActivity">    <!--这里是实现的关键,加入之后底部布局才能上移    这里可以是listview  ,GridView  这类可以滑动的控件-->    <ScrollView        android:id="@+id/layout_scroll"        android:layout_width="match_parent"        android:layout_height="match_parent">    </ScrollView>    <Button        android:id="@+id/btn_bottom"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_alignParentBottom="true" />    <RelativeLayout        android:id="@+id/layout_bottom"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_above="@+id/btn_bottom"        android:background="#FFD8d8d8"        android:clickable="true"        android:padding="5dp">        <EditText            android:id="@+id/edit"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:layout_marginRight="90dp"            android:hint="请输入常用汉字" />        <EditText            android:id="@+id/edit2"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:layout_below="@id/edit"            android:layout_marginRight="90dp"            android:hint="请输入常用汉字" />    </RelativeLayout></RelativeLayout>

0 0