edittext Android ui优化
来源:互联网 发布:王者荣耀用java还是c 编辑:程序博客网 时间:2024/06/06 18:40
1.编辑完 点击下一步 到另一个edittext
设置3个属性:
android:singleLine=”true”
android:imeOptions=”actionNext”
android:nextFocusForward=”@+id/et_pwd”
<LinearLayout android:id="@+id/login_info" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" android:layout_marginTop="30dp" android:gravity="center_horizontal" android:orientation="vertical" > <EditText android:id="@+id/et_user" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="@dimen/common_drawablePadding5" android:gravity="center_vertical" android:textCursorDrawable="@drawable/shape_edittext_cursor" android:singleLine="true" android:hint="请输入账号" android:drawableLeft="@mipmap/ic_persion" android:drawablePadding="15dp" android:background="@null" android:textColorHint="@color/login_color" android:textColor="@color/login_color" android:textSize="@dimen/text14" android:imeOptions="actionNext" android:nextFocusForward="@+id/et_pwd" /> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/login_color"></View> <EditText android:id="@+id/et_pwd" android:layout_marginTop="@dimen/common_drawablePadding20" android:layout_marginBottom="@dimen/common_drawablePadding5" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:singleLine="true" android:drawableLeft="@mipmap/ic_lock" android:textCursorDrawable="@drawable/shape_edittext_cursor" android:drawablePadding="15dp" android:hint="请输入密码" android:background="@null" android:inputType="textPassword" android:textColorHint="@color/login_color" android:textColor="@color/login_color" android:textSize="@dimen/text14" /> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/login_color"></View> </LinearLayout>
2.edittext 要求被输入法顶起来
activity里:代码,
布局参考上面的代码;
//加入滚动 mInputLayout = (LinearLayout) findViewById(R.id.login_info); rLayout = ((LinearLayout) findViewById(R.id.root)); //输入法到底部的间距(按需求设置) final int paddingBottom = DisplayUtil.dp2px(this, 5); rLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { Rect r = new Rect(); rLayout.getWindowVisibleDisplayFrame(r); //r.top 是状态栏高度 int screenHeight = rLayout.getRootView().getHeight(); int softHeight = screenHeight - r.bottom ; Log.e("test","screenHeight:"+screenHeight); Log.e("test","top:"+r.top); Log.e("test","bottom:"+r.bottom); Log.e("test", "Size: " + softHeight); if (softHeight>100){//当输入法高度大于100判定为输入法打开了 rLayout.scrollTo(0, softHeight+paddingBottom); }else {//否则判断为输入法隐藏了 rLayout.scrollTo(0, paddingBottom); } } });
阅读全文
0 0
- edittext Android ui优化
- android ui EditText
- Android UI, EditText, AutoCompleteTextView
- Android UI(EditText)详解
- Android常用UI组件 - EditText
- Android UI详解之EditText
- Android UI学习之EditText
- Android优化-ui优化
- android优化之UI优化
- Android 性能优化 UI优化
- Android-性能优化-UI优化
- android优化-UI优化总结
- [译]Android UI 优化
- Android UI 优化 1
- Android UI 优化 2
- Android UI 优化3
- Android UI 优化4
- android UI优化
- 【C++】 运算符重载
- Web系统大规模并发——电商秒杀与抢购
- 微服务
- clearcanvas 相关资料
- RSA签名和验签
- edittext Android ui优化
- top k 问题解决
- 随手画个圆,你是怎么画的?我们分析了10万个圆,得到了这样的结论
- Python实例浅谈之二自定义异常
- 大咖 | 王汉生:从数据到价值的转化,回归分析的“道”与“术”
- 40个Java多线程问题总结
- 前端框架
- Seafile
- VMware Workstation Pro 下安装Liunx系统