Android 无法在xml中对齐按钮和文本视图

Android 无法在xml中对齐按钮和文本视图,android,xml,android-layout,Android,Xml,Android Layout,我在对齐按钮和文本视图时遇到问题。我已经有了一个xml文本视图和按钮,我想要另一组,就在它们下面。 但我无法补充。请看一看 这是xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_he

我在对齐按钮和文本视图时遇到问题。我已经有了一个xml文本视图和按钮,我想要另一组,就在它们下面。 但我无法补充。请看一看

这是xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:animateLayoutChanges="true"
    android:background="#FFFFFF">

     <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal|top">
    <com.aavishkaar.quikies.widget.TypedfacedTextViewxmlns:your_namespace="http://schemas.android.com/apk/res/com.aavishkaar.quickies"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Click Here"
        android:id="@+id/textView"
        android:layout_weight="0.6"
        android:textSize="24sp"
        android:textColor="@android:color/black"
        android:gravity="center|left"
        android:layout_marginLeft="15dp"
        your_namespace:typeface="Roboto-Regular.ttf" />

    <Button style="?android:attr/buttonStyleSmall"
        android:id="@+id/blue0"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:text="OFF"
        android:layout_weight="0.2"
        android:layout_gravity="center_vertical"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:background="@drawable/switch_bg_holo_light" />

    <Button style="?android:attr/buttonStyleSmall"
        android:id="@+id/blue1"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:text="ON"
        android:layout_weight="0.2"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:layout_marginRight="5dp"
        android:background="@drawable/switch_thumb_activated_holo_light"/>
    </LinearLayout>
</LinearLayout>

添加

如果不忽略这个答案,我希望这会奏效。
我不太擅长这个

试试这段代码,在第一个线性布局中更改方向默认情况下线性布局方向为水平

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:animateLayoutChanges="true"
      android:background="#FFFFFF"
        android:orientation="vertical">


 <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal|top">


<com.aavishkaar.quikies.widget.TypedfacedTextView
          xmlns:your_namespace="http://schemas.android.com/apk/res/com.aavishkaar.quickies"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Click Here"
        android:id="@+id/textView"
        android:layout_weight="0.6"
        android:textSize="24sp"
        android:textColor="@android:color/black"
        android:gravity="center|left"
        android:layout_marginLeft="15dp"
        your_namespace:typeface="Roboto-Regular.ttf"
        />

<Button
        style="?android:attr/buttonStyleSmall"
        android:id="@+id/blue0"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:text="OFF"
        android:layout_weight="0.2"
        android:layout_gravity="center_vertical"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:background="@drawable/switch_bg_holo_light"

        />

<Button
        style="?android:attr/buttonStyleSmall"
        android:id="@+id/blue1"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:text="ON"
        android:layout_weight="0.2"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:layout_marginRight="5dp"
        android:background="@drawable/switch_thumb_activated_holo_light"
        />
</LinearLayout>



非常感谢。成功了!:)你知道如何在它们之间添加一条线,即分隔线。添加一个线性布局,方向为水平,高度为2dp,或者根据你的需要添加背景。第二组不可见或不对齐?
    android:orientation="horizontal" in Second Linear Layour.
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:animateLayoutChanges="true"
      android:background="#FFFFFF"
        android:orientation="vertical">


 <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal|top">


<com.aavishkaar.quikies.widget.TypedfacedTextView
          xmlns:your_namespace="http://schemas.android.com/apk/res/com.aavishkaar.quickies"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Click Here"
        android:id="@+id/textView"
        android:layout_weight="0.6"
        android:textSize="24sp"
        android:textColor="@android:color/black"
        android:gravity="center|left"
        android:layout_marginLeft="15dp"
        your_namespace:typeface="Roboto-Regular.ttf"
        />

<Button
        style="?android:attr/buttonStyleSmall"
        android:id="@+id/blue0"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:text="OFF"
        android:layout_weight="0.2"
        android:layout_gravity="center_vertical"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:background="@drawable/switch_bg_holo_light"

        />

<Button
        style="?android:attr/buttonStyleSmall"
        android:id="@+id/blue1"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:text="ON"
        android:layout_weight="0.2"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:layout_marginRight="5dp"
        android:background="@drawable/switch_thumb_activated_holo_light"
        />
</LinearLayout>
  <com.aavishkaar.quikies.widget.TypedfacedTextView               
   xmlns:your_namespace="http://schemas.android.com/apk/res/com.aavishkaar.quickies"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Click Here"
        android:id="@+id/textView"
        android:layout_weight="0.6"
        android:textSize="24sp"
        android:textColor="@android:color/black"
        android:gravity="center|left"
        android:layout_marginLeft="15dp"
        your_namespace:typeface="Roboto-Regular.ttf"
        />

<Button
        style="?android:attr/buttonStyleSmall"
        android:id="@+id/blue0"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:text="OFF"
        android:layout_weight="0.2"
        android:layout_gravity="center_vertical"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:background="@drawable/switch_bg_holo_light"

        />

<Button
        style="?android:attr/buttonStyleSmall"
        android:id="@+id/blue1"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:text="ON"
        android:layout_weight="0.2"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:layout_marginRight="5dp"
        android:background="@drawable/switch_thumb_activated_holo_light"
        />
</LinearLayout>

</LinearLayout>