Как сделать Android Progressbar как наложение поверх макета - PullRequest
0 голосов
/ 09 марта 2020

У меня есть ниже файл макета. Мне нужно показать Progressbar в макете. В настоящее время Progressbar занимает пустое пространство в середине, поэтому он делит мой вид сверху и снизу при отображении панели, но я пытаюсь показать индикатор в виде наложения поверх макета, чтобы он не занять любое место. Как я могу добиться этого

Это файл макета в настоящее время у меня

<?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="wrap_content"
    android:orientation="vertical">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:orientation="horizontal">

        <ImageView
            android:id="@+id/imgLeftArrow"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/left_arrow2"></ImageView>


        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:gravity="center_horizontal">

            <ImageView
                android:id="@+id/imgGreendot"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/green_dot"></ImageView>

            <TextView
                android:id="@+id/tvStatus"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                ></TextView>

        </LinearLayout>


        <ImageView
            android:id="@+id/imgBid"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
           ></ImageView>

    </RelativeLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:gravity="center_horizontal"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/tvExpected"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            ></TextView>

        <TextView
            android:id="@+id/tvTotalBid"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Total Bids | "
            android:textColor="#a9a9a9"
            android:textSize="14dp"></TextView>

        <TextView
            android:id="@+id/tvDeclined"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            ></TextView>
    </LinearLayout>


    <ProgressBar
        android:id="@+id/progressBar5"
        style="?android:attr/progressBarStyle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:indeterminate="true"
        android:visibility="visible" />


    <LinearLayout
        android:id="@+id/layoutswitch"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <Switch
            android:id="@+id/switch1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_weight="1"
            android:text="Show Active Drivers Only" />
    </LinearLayout>


</LinearLayout>

1 Ответ

2 голосов
/ 09 марта 2020

Использовать макет ограничения

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

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


        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:orientation="horizontal">

            <ImageView
                android:id="@+id/imgLeftArrow"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/abc_vector_test" />


            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:gravity="center_horizontal">

                <ImageView
                    android:id="@+id/imgGreendot"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/abc_vector_test" />

                <TextView
                    android:id="@+id/tvStatus"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />

            </LinearLayout>


            <ImageView
                android:id="@+id/imgBid"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

        </RelativeLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:gravity="center_horizontal"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/tvExpected"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <TextView
                android:id="@+id/tvTotalBid"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Total Bids | "
                android:textColor="#a9a9a9"
                android:textSize="14dp" />

            <TextView
                android:id="@+id/tvDeclined"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
        </LinearLayout>


        <LinearLayout
            android:id="@+id/layoutswitch"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <Switch
                android:id="@+id/switch1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_weight="1"
                android:text="Show Active Drivers Only" />
        </LinearLayout>

    </LinearLayout>

    <ProgressBar
        android:id="@+id/progressBar5"
        style="?android:attr/progressBarStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:indeterminate="true"
        android:visibility="visible"
        app:layout_constraintBottom_toBottomOf="@+id/linearLayout3"
        app:layout_constraintEnd_toEndOf="@+id/linearLayout3"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@+id/linearLayout3" />


</androidx.constraintlayout.widget.ConstraintLayout>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...