android - 我怎样才能让 View 不扩展到它的兄弟 View

标签 android layout

我有一个类似这样的布局:

<RelativeLayout ...>
     <EditText android:id="@+id/editbox" 
            android:layout_width="wrap_content" .../>
     <Button android:layout_right="@id/editbox" 
            android:layout_width="wrap_content"
            android:text="Button" />
 </RelativeLayout>

按钮位于编辑文本的右侧。编辑文本是“wrap_content”。当我在编辑 View 中键入文本时, View 的宽度会增加并将扩展到我的按钮。我希望这两个 View (按钮和编辑文本)有自己的区域。如何配置?

最佳答案

嗨 Keyin Lynx:使用 minWidth 和 maxWidth 属性,例如:

android:minWidth="10dip", android:maxWidth="60dip", 属性。

关于android - 我怎样才能让 View 不扩展到它的兄弟 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4496090/

相关文章:

android - 使用命名空间检测android应用程序?

android - 如何在 android TextView 中显示 html 特殊字符

xaml - 网格不占用 100% 宽度

java - 弹出创建java Swing

android - 用 ConstraintLayout 模仿 TableLayout

jquery - CSS 挑战 : jQuery's slideDown-like on a specific particular layout

java - 在 EditText 的日期中添加斜线

android - 我在哪里可以浏览 java.lang.String 的 Android 2.2 Froyo 源代码?

xml - 使用 Android 生成的 ant 构建文件时如何为 JAR 指定 lib 文件夹?

css - 具有 1 个绝对宽度 float 和 1 个相对 float 的相对宽度容器