我正在开发 android 应用程序,我想在其中修复编辑字段框的大小。例如,如果我想在上面添加 100 个单词,那么它不会增加编辑字段的大小。字符应保留在框内而不增加编辑文本的大小。我已将 editText 的 xml 代码与图像一起粘贴。
<EditText
android:id="@+id/fnametxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.1"
android:background="@color/Beige"
android:enabled="false"
android:lines="1"
android:ems="15"
android:maxLines="1"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="ufyufgiuhjlkh"
android:textColor="@color/Black"
android:textSize="12sp" />
提前致谢
最佳答案
固定字段的宽度。
您可以通过多种方式做到这一点:
带权重的线性布局。你的容器应该有
android:weightSum="100"
(你可以放置你的号码而不是 100)。例如你可以去here或 here .使用权重,您应该设置android:layout_width="0dp"
以查看结果。带边距的 RelativeLayout。将第一个 EditText 设置为
android:layout_alignParentRight="true"
和android:layout_toRightOf="IdOfTextView"
。将右边距设置为(例如)10dp。 EditField 将被拉伸(stretch)以填充所有可用空间。您可以将
android:maxWidth
设置为某个以 dp 或 px 为单位的值。或者 maxLength或 maxEms可以做到这一点。
关于android - 如何使编辑字段android的固定大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27606154/