C# 布局不会到底部!它';他在旁边

C# 布局不会到底部!它';他在旁边,c#,visual-studio,android-layout,xamarin,xamarin.android,C#,Visual Studio,Android Layout,Xamarin,Xamarin.android,当我创建一个新布局时,它会出现在屏幕的右侧。我希望它在底部,在我的线性布局下面。图片中的例子 确保将父布局的方向设置为垂直。默认情况下,它是水平的 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.

当我创建一个新布局时,它会出现在屏幕的右侧。我希望它在底部,在我的线性布局下面。图片中的例子


确保将父布局的方向设置为垂直。默认情况下,它是水平的

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
<!-- your inner layouts here -->
</LinearLayout>


您是否希望获得如下效果?

如果是这样,您可以将
android:gravity=“bottom”
添加到外部
LinearLayout
,这是我的布局xml(如果您希望布局到底部中心,可以使用
android:gravity=“bottom | center”

>

您可以将XML发布到布局中吗?从图像中可以看出,按钮与表单字段的父布局不同。您可以共享您的代码吗?稍后我将共享它。我希望我的输入布局位于顶部,按钮位于底部。两个宽度都应该与父布局相同,即whe宽度。@RokasStulga我更新我的答案,你需要吗?是的,这是我需要的。现在我去看看这是否有效。@RokasStulga好的,等待你的更新。如果回复有帮助,请不要忘记将其标记为答案(单击✔ 在这个答案的右上方),它将帮助其他有类似问题的人。
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"   
android:gravity="bottom"
>

<LinearLayout
    android:layout_width="200dp"
    android:layout_height="wrap_content"
    android:orientation="vertical"


    >
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="text"
        android:hint="First Name"
/>
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="text"
        android:hint="Last Name"
/>
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="text"
        android:hint="UserName"
/>
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="text"
        android:hint="Password"
/>
    <LinearLayout
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <CheckBox
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Show Password"
            android:textColor="@android:color/black"            
        />
    </LinearLayout>
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="text"
        android:hint="Email"
/>
</LinearLayout>
android:layout_width="match_parent"
android:layout_height="match_parent"

>
    >
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="text"
        android:hint="First Name"
/>
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="text"
        android:hint="Last Name"
/>
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="text"
        android:hint="UserName"
/>
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="text"
        android:hint="Password"
/>
    <LinearLayout
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <CheckBox
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Show Password"
            android:textColor="@android:color/black"            
        />
    </LinearLayout>
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="text"
        android:hint="Email"
/>
</LinearLayout>