android开发 Edittext编辑框超出屏幕
2015-07-29 16:04
411 查看
今天导入一段别人写的计算器源码,运行后发现编辑框里的数字有一部分在屏幕外面,如下图所示:
但是我的布局设置的是match parent,无法理解为什么会出现这种情况。
<EditText android:id="@+id/result"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:layout_span="4"
android:textSize="48sp"
android:gravity="right|center_vertical"
android:cursorVisible="false"
android:editable="true"
android:lines="1" />
后来我进入到Graphical layout中预览,发现也是这种情况,如下图所示:
后来将Api22调到Api17,发现Graphical layout中预览的编辑框终于不超出屏幕外了:
自此,我以为问题解决了。运行程序结果编辑框还是在屏幕外。百撕不得骑姐。。
后来尝试无数次,最后在加入layout_weight属性才终于解决问题,什么原因现在还不清楚。
<EditText android:id="@+id/result"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:layout_span="4"
android:textSize="48sp"
android:gravity="right|center_vertical"
android:cursorVisible="false"
android:editable="true"
android:lines="1"
android:layout_weight="1" />
但是我的布局设置的是match parent,无法理解为什么会出现这种情况。
<EditText android:id="@+id/result"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:layout_span="4"
android:textSize="48sp"
android:gravity="right|center_vertical"
android:cursorVisible="false"
android:editable="true"
android:lines="1" />
后来我进入到Graphical layout中预览,发现也是这种情况,如下图所示:
后来将Api22调到Api17,发现Graphical layout中预览的编辑框终于不超出屏幕外了:
自此,我以为问题解决了。运行程序结果编辑框还是在屏幕外。百撕不得骑姐。。
后来尝试无数次,最后在加入layout_weight属性才终于解决问题,什么原因现在还不清楚。
<EditText android:id="@+id/result"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:layout_span="4"
android:textSize="48sp"
android:gravity="right|center_vertical"
android:cursorVisible="false"
android:editable="true"
android:lines="1"
android:layout_weight="1" />
相关文章推荐
- Android实现表情 抓取新浪表情
- 详解Android解析Xml的三种方式——DOM、SAX以及XMLpull
- MyEclipse Web Project转Eclipse Dynamic Web Project
- Windows Clang开发环境备忘
- 让Flex Builder 3.0与Eclipse3.4整合起来
- Eclipse配置Javascript开发环境图文教程
- 使用zend studio for eclipse不能激活代码提示功能的解决办法
- ext for eclipse插件安装方法
- 解决Fedora14下eclipse进行android开发,ibus提示没有输入窗口的方法详解
- android开发环境遇到adt无法启动的问题分析及解决方法
- Android开发 旋转屏幕导致Activity重建解决方法
- eclipse导入jquery包后报错的解决方法
- Android开发技巧之在a标签或TextView控件中单击链接弹出Activity(自定义动作)
- Eclipse 格式化代码时不换行与自动换行的实现方法
- Eclipse下jQuery文件报错出现错误提示红叉
- eclipse如何忽略js文件报错(附图)
- eclipse3.2.2 + MyEclipse5.5 + Tomcat5.5.27 配置数据库连接池
- jquery库或JS文件在eclipse下报错问题解决方法
- 什么是eclipse,eclipse的意思解析
- Zend Studio for Eclipse的java.lang.NullPointerException错误的解决方法