android – EditText不会填满余下的空间

android – EditText不会填满余下的空间,第1张

概述所以我有这个textview“To”,一个用于输入联系人的edittext和一个搜索按钮,用于在一行中搜索所有联系人. textview和按钮都很好,但问题是edittext很小,我希望它占用所有剩余的空间.这是代码: <RelativeLayout android:layout_height="wrap_content" android:layout_wi 所以我有这个textvIEw“To”,一个用于输入联系人的edittext和一个搜索按钮,用于在一行中搜索所有联系人. textvIEw和按钮都很好,但问题是edittext很小,我希望它占用所有剩余的空间.这是代码:
<relativeLayout          androID:layout_height="wrap_content"          androID:layout_wIDth="fill_parent"        androID:paddingtop="10dp">        <TextVIEw              androID:layout_wIDth="wrap_content"             androID:layout_height="wrap_content"             androID:text="To: "            androID:textcolor="#000000"            androID:paddingtop="10dp"            androID:layout_toleftOf="@+ID/editText_recipIEnt"            androID:layout_alignParentleft="true"            androID:layout_marginleft="10dp"/>         <EditText            androID:ID="@+ID/editText_recipIEnt"            androID:layout_height="wrap_content"            androID:layout_wIDth="wrap_content"               androID:hint="Enter Number"              androID:inputType="number"            androID:textSize="12sp"            androID:layout_toleftOf="@+ID/button_recipIEnt_picker"              androID:layout_marginleft="5dp"/>        <button              androID:ID="@+ID/button_recipIEnt_picker"             androID:layout_height="wrap_content"               androID:layout_wIDth="wrap_content"              androID:text="browse .."              androID:layout_alignParentRight="true"             androID:layout_marginleft="5dp"            androID:layout_marginRight="5dp"            androID:onClick="dolaunchContactPicker"/>        </relativeLayout>
解决方法
<linearLayout          androID:layout_height="wrap_content"          androID:layout_wIDth="fill_parent"        androID:paddingtop="10dp">        <TextVIEw              androID:layout_wIDth="wrap_content"             androID:layout_height="wrap_content"             androID:text="To: "            androID:textcolor="#000000"            androID:paddingtop="10dp"            androID:layout_marginleft="10dp"/>         <EditText            androID:ID="@+ID/editText_recipIEnt"            androID:layout_height="wrap_content"            androID:layout_wIDth="wrap_content"               androID:hint="Enter Number"              androID:inputType="number"            androID:textSize="12sp"            androID:layout_marginleft="5dp"            androID:layout_weight="1"         />        <button              androID:ID="@+ID/button_recipIEnt_picker"             androID:layout_height="wrap_content"               androID:layout_wIDth="wrap_content"              androID:text="browse .."              androID:layout_marginleft="5dp"            androID:layout_marginRight="5dp"            androID:onClick="dolaunchContactPicker"/>        </linearLayout>

使用此布局,我将您的布局转换为线性(水平默认).并为editText添加了layout_weight,它将占用剩余的空间.

总结

以上是内存溢出为你收集整理的android – EditText不会填满余下的空间全部内容,希望文章能够帮你解决android – EditText不会填满余下的空间所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1137290.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存