Есть ли способ сложить виджеты снизу в linearlayout? - PullRequest
0 голосов
/ 07 мая 2019

При определении Linearlayout виджеты типа Button, Edittext будут складываться сверху.Например, приведенный ниже код будет отображаться как this

    <LinearLayout

        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <Button
            android:text="button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <EditText
            android:text="edittext"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <Button
            android:text="button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <EditText
            android:text="edittext"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </LinearLayout>

Можно ли добавить кнопки и тексты редактирования, начиная с нижней части макета, без использования layout_weight?

1 Ответ

0 голосов
/ 07 мая 2019

добавьте android:gravity="bottom" к корневому макету:

<LinearLayout

    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="bottom" \\ add this line
    android:orientation="vertical">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="button" />

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="edittext" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="button" />

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="edittext" />

</LinearLayout>
...