кнопка с плавающим действием в линейном выводе не отображается - PullRequest
0 голосов
/ 30 апреля 2020

Здравствуйте. Я пытаюсь выровнять плавающую кнопку в правом нижнем углу экрана, но в правом верхнем углу экрана отображается значок. Что можно сделать, чтобы перейти в правый нижний угол?

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:theme="@style/AppTheme"
    android:orientation="vertical"
    tools:context=".MainActivity">
    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/createRoomButton"
        style="@style/Widget.MaterialComponents.FloatingActionButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|right"
        android:layout_margin="16dp"
        app:srcCompat="@drawable/ic_add_black_24dp"/>

    <SearchView
        android:id="@+id/searchInput"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:iconifiedByDefault="false"
        android:queryHint="Search Rooms">
        <requestFocus />
    </SearchView>

    <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
        android:id="@+id/pullToRefresh"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <ListView
            android:id="@+id/roomList"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            />

    </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>






</LinearLayout>

1 Ответ

0 голосов
/ 30 апреля 2020

Внесены необходимые изменения в ваш пользовательский интерфейс, и теперь он отлично работает:

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:theme="@style/AppTheme"
    android:orientation="vertical"
    tools:context=".MainActivity">

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

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/createRoomButton"
        style="@style/Widget.MaterialComponents.FloatingActionButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="22dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        app:srcCompat="@drawable/ic_add_black_24dp"/>



    <SearchView
        android:id="@+id/searchInput"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:iconifiedByDefault="false"
        android:layout_marginTop="50dp"
        android:queryHint="Search Rooms">
        <requestFocus />
    </SearchView>

    <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
        android:id="@+id/pullToRefresh"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <ListView
            android:id="@+id/roomList"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            />

    </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
    </RelativeLayout>
    </LinearLayout>

enter image description here

...