设置在同一条直线上的文本框 [英] Setting up textboxes in same straight line
问题描述
请看看下面code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/firstNumber"
/>
<EditText
android:id="@+id/firstNumberTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/secondNumber"
/>
<EditText
android:id="@+id/secondNumberTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<RadioGroup
android:id="@+id/radioGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<RadioButton
android:id="@+id/sum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sum"
/>
<RadioButton
android:id="@+id/min"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/min"
/>
<RadioButton
android:id="@+id/max"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/max"
/>
<RadioButton
android:id="@+id/dev"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dev"
/>
</RadioGroup>
</LinearLayout>
这code的输出GUI附于图像
The output GUI of this code is attached as an image
不过,你可以看到一个文本框在另一个之前开始,使得界面难看。我需要在同一个列中显示文本框,在一直线上。举一个例子,如果文本框1开始在X = 1和Y = 1,第二个文本框应该开始在X = 1且Y = 2,这个例子是在Java中的情况下。请帮助!
However, you can see that one text box is starting before the other one, making the GUI ugly. I need to display the textboxes in the same column, in a one straight line. For an example, if the text box 1 is starting at X=1 and Y=1, the second textbox should start in X=1 and Y=2, this example is in case of Java. Please help!
推荐答案
使用固定大小为您TextViews(例如的android:layout_width =20dip
这两个视图)。或使用 TableLayout 显示两列:第一列将存储TextViews,第二个会有EditTexts。
Use fixed size for your TextViews (e.g. android:layout_width="20dip"
for both Views). Or use TableLayout for displaying two columns: the first column will store TextViews, the second one will have EditTexts.
这篇关于设置在同一条直线上的文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!