Java 在Android XML中对齐textview和progressbar

Java 在Android XML中对齐textview和progressbar,java,android,xml,Java,Android,Xml,我已经尝试将smallprogressbar与textview对齐,将它们放入一个线性布局中,但它不起作用。尝试使用android:layout\u gravity=“left”但它崩溃了 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_par

我已经尝试将smallprogressbar与textview对齐,将它们放入一个线性布局中,但它不起作用。尝试使用android:layout\u gravity=“left”但它崩溃了

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:text="@string/calibration_1"
        android:textColor="#33b5e5"
        android:textSize="16dp"
        android:textStyle="bold" />


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <TextView
            android:id="@+id/tvNumberWaves"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:text="@string/calibration_2"
            android:textColor="#FFFFFF"
            android:textSize="18dp" />

        <ProgressBar
            android:id="@+id/progressBar1"
            style="?android:attr/progressBarStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <TextView
            android:id="@+id/tvIntervalWaves"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:text="@string/calibration_3"
            android:textColor="#FFFFFF"
            android:textSize="18dp" />

        <ProgressBar
            android:id="@+id/progressBar2"
            style="?android:attr/progressBarStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>

    <Button
        android:id="@+id/bSetValues"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:text="@string/calibration_5" />

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:text="@string/calibration_6" />
    </ScrollView>

</LinearLayout>


更新代码以匹配您的答案。 我将整个代码都放在这里以显示我所拥有的。

更改这一行:

android:orientation="vertical"
为此:

android:orientation="horizontal"
在看不到其他源代码的情况下,我不知道这是否会打乱布局的其他部分,因此您可能希望将
TextView
ProgressBar
包装在它们自己的
LinearLayout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:text="@string/calibration_1"
        android:textColor="#33b5e5"
        android:textSize="16dp"
        android:textStyle="bold" />


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/tvNumberWaves"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:text="@string/calibration_2"
            android:textColor="#FFFFFF"
            android:textSize="18dp" />

        <ProgressBar
            android:id="@+id/progressBar1"
            style="?android:attr/progressBarStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/tvIntervalWaves"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:text="@string/calibration_3"
            android:textColor="#FFFFFF"
            android:textSize="18dp" />

        <ProgressBar
            android:id="@+id/progressBar2"
            style="?android:attr/progressBarStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>

    <Button
        android:id="@+id/bSetValues"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:text="@string/calibration_5" />

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:text="@string/calibration_6" />
    </ScrollView>

</LinearLayout>


如何对齐它们?并排?是的,我想把圆圈栏放在文本视图旁边。除了第一个文本视图之外的所有东西都消失了。将你想要的两件东西并排包装在它们自己的
线性布局中,不要在
文本视图上使用
填充父项
,用修改过的源代码更新你的问题,然后将根布局更改回垂直布局
将顶部的线性布局
更改回垂直布局,tvNumberWaves和1°进度条对齐,但其他对象消失。更新了代码