我如何prevent从调整自己,当用户键入一个EditText? [英] How do I prevent an EditText from resizing itself when the user is typing?
问题描述
我有一个的EditText
和按钮
毗邻对方在同一水平线上。它看起来很棒,当用户输入大量的文字,除了中,的EditText
调整大小,而按钮
被压扁
我有两个的EditText
和按钮
设置为 layout_width =WRAP_CONTENT
。 FILL_PARENT
食堂布局,我不想使用绝对的大小,如果我没有 - 的方式,它现在看上去很不错的风景和肖像,我只是不想让的EditText
来调整。
我的布局:
< TableLayout
机器人:ID =@ + ID / homelayout
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT>
<的TableRow>
<的TextView
机器人:ID =@ + ID / labelartist
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:文本=查找艺人:/>
< /的TableRow>
<的TableRow>
<的EditText
机器人:ID =@ + ID / entryartist
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_weight =6
机器人:背景=@机器人:可绘制/ editbox_background
机器人:编辑=真
机器人:填充=5像素
机器人:单线=真/>
<按钮
机器人:ID =@ + ID / okartist
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentRight =真
机器人:layout_marginLeft =10dip
机器人:layout_weight =1
机器人:文本=搜索/>
< /的TableRow>
< / TableLayout>
有关的EditText使用
机器人:layout_width =0dp - 不是必需的,但preferred。
机器人:layout_weight =1
而对于巴顿不指定的android:layout_weight
I have an EditText
and a Button
set next to each other on the same horizontal line. It looks great, except when the user enters a lot of text, the EditText
is resized, and the Button
is squished.
I have both EditText
and Button
set to layout_width="wrap_content"
. "fill_parent"
messes up the layout, and I don't want to use absolute sizes if I don't have to - the way it is now looks great in both landscape and portrait, I just don't want the EditText
to resize.
My layout:
<TableLayout
android:id="@+id/homelayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableRow>
<TextView
android:id="@+id/labelartist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Find artists:" />
</TableRow>
<TableRow>
<EditText
android:id="@+id/entryartist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="6"
android:background="@android:drawable/editbox_background"
android:editable="true"
android:padding="5px"
android:singleLine="true" />
<Button
android:id="@+id/okartist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dip"
android:layout_weight="1"
android:text="Search" />
</TableRow>
</TableLayout>
For EditText use
android:layout_width="0dp" - not required but preferred.
android:layout_weight="1"
And for Button dont specify android:layout_weight
这篇关于我如何prevent从调整自己,当用户键入一个EditText?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!