如何使 ImageButton 位于 LinearLayout 的底部

How do I make an ImageButton rest at the bottom of a LinearLayout

XML 文件

<include
    android:id="@id/my_toolbar"
    layout="@layout/toobar"
    />

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:id="@+id/LinearEditTexts"
        >



        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/Title_input"
            />

        <ImageButton
            android:layout_height="wrap_content"
            app:srcCompat="@android:drawable/ic_input_add"
            android:id="@+id/imageButton2"
            android:layout_width="50dp"
            android:layout_gravity="bottom"
            android:onClick="AddNewTextFields"


            />


    </LinearLayout>

</ScrollView>

我的 Java 文件,我在其中以编程方式制作 EdtTexts 列出 alledittexts = new ArrayList();

public void AddNewTextFields(View view) {
    TotalEdittexts++;
    if (TotalEdittexts > 100)
        return;
    EditText editText = new EditText(this);
    Containerlayout.addView(editText);
    editText.setGravity(Gravity.TOP);
    LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) editText.getLayoutParams();
    layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
    layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;

    editText.setLayoutParams(layoutParams);
    //if you want to identify the created editTexts, set a tag, like below
    editText.setTag("AddedEditText" + TotalEdittexts);

    alledittexts.add(editText);

}

每次 onClickListener() 调用该函数时,我都试图让我的图像按钮位于该图像按钮创建的 EditText 下方。
设置它的重力并没有改变任何东西我很想得到一些帮助。

试试这个:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    androidd:orientation="vertical">
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="2">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:id="@+id/linearlayout">
            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />
        </LinearLayout>
    </ScrollView>
    <ImageButton
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:src="@android:drawable/ic_media_rew"/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">



 <include
    android:id="@id/my_toolbar"
    layout="@layout/toobar"
    />

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="2">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:id="@+id/LinearEditTexts"
        >



        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/Title_input"
            />


    </LinearLayout>

</ScrollView>
<ImageButton
    android:layout_width="match_parent"
    android:src="@android:drawable/ic_media_rew"
    android:layout_height="wrap_content" />

</LinearLayout>

这是我的 XML 文件编辑后的样子。
感谢您的回答,它就像一个魅力