[英]Android Problem: EditText, KeyListener and the physical Back Button
[英]Problem with sizes of EditText and Button in Android
我想使edittext宽度与按钮相同。 我的EditText当前很小。 我使用相对布局。
<TextView
android:id="@+id/aha4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="17dip"
android:text="Vzdevek:"
android:layout_below="@id/aha3" />
<EditText android:id="@+id/nick"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="@id/nivo"
android:layout_toRightOf="@id/aha4"/>
<Button android:id="@+id/poslji"
android:text="Pošlji"
android:layout_height="wrap_content"
android:layout_width="20dip"
android:typeface="serif" android:textStyle="bold"
android:layout_alignParentRight="true"
android:layout_below="@id/nivo"
android:layout_toRightOf="@id/nick"/>
我目前得到的是: 替代文本http://www.shrani.si/f/1Z/x8/2lWB3f8p/device.png
edittext和button的适当layout_width是多少?
当您使用类似一行的内容来显示TextView,EditText和按钮时,可以尝试使用TableLayout: http : //developer.android.com/guide/tutorials/views/hello-tablelayout.html
另外,请确保设置android:layout_width="wrap_content"
以便EditText
使用尽可能多的空间。
尝试为按钮和编辑文本分配相等的权重
是的,您的体重是对的。 作为黑客,您可以执行此操作。 虽然不完全正确。
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/aha4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="17dip"
android:text="Vzdevek:" />
<Button
android:id="@+id/poslji"
android:text="Pošlji"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:paddingLeft="40dip"
android:paddingRight="40dip"
android:typeface="serif"
android:textStyle="bold"
android:layout_alignParentRight="true" />
<EditText
android:id="@+id/nick"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_toRightOf="@id/aha4"
android:layout_toLeftOf="@id/poslji" />
</RelativeLayout>
我设法通过为EditText指定minWidth和maxWidth来解决它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.