的EditText正在成长为输入的文本 [英] EditText is growing as text entered

查看:110
本文介绍了的EditText正在成长为输入的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个EditText即在屏幕上,并且应该采取的剩余的20%的一个按钮的80%,但是,当被输入到框中的文本或除去的EditText增大和收缩

I have an edittext that is 80% of the screen across and a button that should take the remaining 20%, but when text is entered into the box or removed the edittext grows and shrinks.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="vertical">

   <LinearLayout
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:orientation="horizontal"
      android:weightSum="100">

      <Button
         android:id="@+id/people_relationFilterB"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_weight="20" />

      <EditText
         android:id="@+id/people_searchBoxET"
         android:text="Search Known"
         android:singleLine="true"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_weight="80" />
   </LinearLayout>

   <ListView
     android:id="@+id/people_listLV"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content" />

</LinearLayout>

任何线索?谢谢!

Any Clues? Thanks!

推荐答案

我相信你的问题是您正在设置的EditText的布局宽度WRAP_CONTENT。我有这个问题,当我开始Android开发也是如此。你基本上是在告诉你希望你的EditText的Andr​​oid自身大小,以适应您输入的文本。

I believe your issue is you are setting the layout width of the EditText as wrap_content. I had this problem when I started Android development as well. You are essentially telling Android that you want your EditText to size itself to fit the text you entered.

的解决方案是设置布局宽度FILL_PARENT,然后,如果需要的包裹一个的LinearLayout围绕它包含大小

The solution is to set the layout width as fill_parent and then if needed wrap a LinearLayout around it to contain the size.

这篇关于的EditText正在成长为输入的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆