How to superimpose a layout on top of another layout?

1

I have a splash screen within a relative layout that is responsible for filling the screen of the mobile with the logo of the app. So far so good, the thing is that I'm trying to implement a progress bar so that as you carry out the checks you increase the progress and once the verifications that jump to the main activity ends.

The problem I have is that the splash screen occupies the whole screen and I do not know how I can do so that the splash screen continues with the function of occupying the whole screen of the device at the same time that I make the progress bar appear on top of the splash screen.

I enclose the xml so you can take a look at it

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SplashScreenActivity"
android:orientation="vertical">

<ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:contentDescription="@string/app_name"
    android:scaleType="fitXY"
    android:src="@drawable/splash_screen"/>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <ProgressBar
        android:id="@+id/progressBar"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1" />

</LinearLayout>

    
asked by Eduardo 21.04.2017 в 11:46
source

1 answer

4

With a LinearLayout within your RelativeLayout you can solve your problem.

The RelativeLayout lets you superimpose elements and establish a hierarchical relationship.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".SplashScreenActivity">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:contentDescription="@string/app_name"
        android:scaleType="fitXY"
        android:src="@drawable/splash_screen"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_marginBottom="?attr/actionBarSize"
        android:layout_alignParentBottom="true">

        <ProgressBar
            android:id="@+id/progressBar"
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_gravity="center_vertical|center_horizontal"
            android:layout_weight="1" />

    </LinearLayout>

</RelativeLayout>

Here is a link to the documentation: RelativeLayouts

    
answered by 21.04.2017 / 12:08
source