您的位置:首页 > 移动开发 > Android开发

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

2016-12-20 14:45 399 查看
两种方案
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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android