Why does it shows good in the editor and something completely different in the emulator?

35 Views Asked by At

I'm designing my Android app in Android studio. In design view it looks like I want to but in the emulator completely different. All constraints have been added. And I would like to know how to fix the bottom bar navigation view. What should I do?

screenshot of preview next to emulator

Xml code:

<androidx.constraintlayout.widget.ConstraintLayout 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:fitsSystemWindows="true">

    <ScrollView
        android:id="@+id/scrollView3"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/background_color"
        android:scrollbars="none"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintVertical_bias="1.0">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/constraintLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="623dp"
            android:background="@color/pink2">

            <TextView
                android:id="@+id/textView7"
                android:layout_width="118dp"
                android:layout_height="wrap_content"
                android:layout_marginStart="32dp"
                android:layout_marginTop="32dp"
                android:text="Hello!"
                android:textColor="@color/black"
                android:textSize="30sp"
                android:textStyle="bold"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <ImageView
                android:id="@+id/imageView"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginBottom="-30dp"
                android:scaleType="fitEnd"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:srcCompat="@drawable/asset_3"
                tools:srcCompat="@drawable/asset_2" />

        </androidx.constraintlayout.widget.ConstraintLayout>
    </ScrollView>

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottom_navigation"
        style="@style/Widget.MaterialComponents.BottomNavigationView.Colored"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="12dp"
        android:paddingBottom="16dp"
        app:itemIconSize="24dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:menu="@menu/bottom_navigation_menu" />

</androidx.constraintlayout.widget.ConstraintLayout>
1

There are 1 best solutions below

0
Mateus Bauer On

What's wrong with the bottom navigation view? If you mean the light bar above it, it´s the gesture soft navigation bar, you can´t hide it, unless you request your activity window to enter fullscreen, but I think you don't want that. I suggest you to remove the ConstraintLayout marginBottom and try some different scaleTypes in the ImageView, like: android:scaleType="center" or android:scaleType="centerCrop".