【问题标题】:Android "text" next to "Text Field" box“文本字段”框旁边的Android“文本”
【发布时间】:2011-12-29 22:49:16
【问题描述】:

我是 Android 开发的新手,我有一个愚蠢的问题。如何将“文本字段”框放在单行中的文本旁边。

例子:

Please Enter the number:   [        ] <--- this should be the textfield. 

谢谢。

【问题讨论】:

    标签: android text textfield


    【解决方案1】:

    正如上面其他人所说..您必须将它们放在 LinearLayout 或 RelativeLayout 中。由于您刚刚开始,我建议您改用 LinearLayout。这样的事情应该可以工作。

    <LinearLayout android:orientation="horizontal" 
              android:layout_height="wrap_content"
              android:layout_width="fill_parent">
    
    <TextView android:text="Please Enter The Number:"
              android:layout_height="wrap_content"
              android:layout_width = "wrap_content"/>
    
    <EditText android:layout_height="wrap_content"
              android:layout_width="wrap_content"/>
    
    
    </LinearLayout>
    

    【讨论】:

    • 非常感谢大家。这就像一个魅力。我想控制 EditTex,比如给它们与边缘的距离
    • 如果这回答了您的原始问题,请将其作为答案提交。另外,根据我从您的后续问题中得到的信息,您正在寻找的“与边缘的距离”是一个称为填充的属性。将此行添加到您的 TextView 或 EditText 标记。安卓:填充=“5dp”。您还可以在可视化编辑器中使用其他属性,只需右键单击小部件,然后 -> 属性。我建议您使用 Layout Gravity、LayoutMarginRight、LayoutPadding 等。这些可以让您更好地控制视图的显示和位置
    • 你太棒了。非常感谢。
    【解决方案2】:

    您可以使用LineraLayout(或)RelativeLayout(或)TableLayout

    这是一个很好的例子:Android Layout Tutorial

    【讨论】:

      【解决方案3】:

      例如,您可以将它们并排放置在水平 LinearLayout 中。或者在 TableLayout 的两列中。顺便说一句。要使用的组件是 TextView 和 EditText

      【讨论】:

      • 你有例子吗?谢谢
      猜你喜欢
      • 1970-01-01
      • 2016-03-03
      • 1970-01-01
      • 2021-06-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-04
      • 2021-12-28
      相关资源
      最近更新 更多