Android顶部布局View不随着输入框弹出而上移
来源:互联网 发布:java ssi框架 编辑:程序博客网 时间:2024/06/05 10:30
前提
平时我们需要实现布局底部布局View随着输入框弹出而上移的效果,但是有些时候我们需要实现顶部布局View不随着输入框弹出而上移,比如自定义的Activity的title,这个时候就不希望随着输入框弹出而title也上移。以为此时title上移就看不见了。所以我们需要实现顶部title View不随着输入框的弹出而上移。
实现的主要代码是布局文件,实现如下:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/colorAccent" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="此处为顶部固定View,不随着输入框弹出而上移" android:textColor="@android:color/white" android:textSize="20sp" /> </LinearLayout> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/white"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="此处为内容区域,随着输入框弹出而上移" android:textSize="20sp" /> <EditText android:layout_width="match_parent" android:layout_height="100dp" android:layout_marginTop="400dp" /> </LinearLayout> </ScrollView></LinearLayout>
解析:
- 把不随着输入框弹出而上移的View布局不放在ScrollView中
- 把需要随着输入框弹出而上移的View布局放在ScrollView中
注意:ScrollView 不能添加 android:scrollbars=”none” 属性,否则不能达到预期效果。
阅读全文
0 0
- Android顶部布局View不随着输入框弹出而上移
- 设置布局不随输入框键盘出现而上移
- Android:如何设置底部控件view随着软键盘的弹出而上移——诺诺"涂鸦"记忆
- 实现view底部控件随着键盘的弹出而上移的效果
- Android监听软键盘,布局上移不遮挡输入框
- IOS 键盘弹出遮挡输入框使view上移
- 输入框随着键盘上移,键盘回收
- 弹出键盘 输入框上移
- iOS TextField 弹出键盘时实现view整体上移下移:防止弹出键盘遮挡输入框
- [Phonegap+Sencha Touch] 移动开发24 打包wp8.1的App,运行时输入框聚焦弹出软键盘之后,界面上移而不恢复原位的解决办法
- [Phonegap+Sencha Touch] 移动开发24 打包wp8.1的App,运行时输入框聚焦弹出软键盘之后,界面上移而不恢复原位的解决办法
- android 软键盘弹出 布局上移动
- iOS TextField输入框点击键盘时随着键盘上移
- 输入框弹出键盘时自动上移
- 输入框键盘弹出视图相应上移
- TextField随着键盘的弹出上移
- Android ListView 内容随着键盘弹出而向上推
- Android ListView 内容随着键盘弹出而向上推
- Preference 系统自带的偏好设置页面解析
- kernel.sem 参数设置
- Listview的性能优化与viewholder是否需要设置成static
- zabbix安装参考
- Android Studio快捷键
- Android顶部布局View不随着输入框弹出而上移
- java基础复习-数据类型
- 在 Linux 命令行中使用和执行 PHP 代码(一)
- mysql python adapter安装
- 分词工具介绍比较
- CSS 类和ID的常用命名:
- String、StringBuffer与StringBuilder的区别
- php连接 mysql的三种连接方式
- CentOS6.5安装与配置Mysql数据库