Problem with Bottonnavigationview

Asked

Viewed 68 times

0

inserir a descrição da imagem aqui

As you can see I’m with a little problem of layout in this form on Android, this form is opened inside a Fragment normally where I will send this data.

1- To my surprise the EditText does not expand to the whole screen. I have tried using Layoutparams setando matchparent but nothing happened...

2- Buttons are hiding behind the BottonNavigationView, I’ve tried to put a scrollview there but he does not leave there...

This component BottonNavigation it has to stay fixed on the screen because I don’t want it to hide with the Behavior function... Bottonnavigation

Would anyone have any hint to try to fit this form properly or some help from beyond ?

This layout is here:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:id="@+id/layouparams"
    android:layout_height="match_parent"
    android:orientation="vertical">

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

        <com.vicmikhailau.maskededittext.MaskedEditText
            android:id="@+id/reg_txt_nome"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Nome Ex.: Pedro Silva"
            android:inputType="text"
            />

        <com.vicmikhailau.maskededittext.MaskedEditText
            android:id="@+id/reg_txt_email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Email Ex.: [email protected]"
            android:inputType="textEmailAddress"
            />


        <com.vicmikhailau.maskededittext.MaskedEditText
            android:id="@+id/reg_txt_datanasc"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Data Nasc Ex.: 01/01/1980"
            android:inputType="number"
            android:maxLength="10"

            app:mask="##/##/####" />

        <com.vicmikhailau.maskededittext.MaskedEditText
            android:id="@+id/reg_txt_contato"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Contato Ex.: (16)9999-00-99"
            android:inputType="number"
            android:maxLength="14"

            app:mask="(##)####-##-##" />

        <com.vicmikhailau.maskededittext.MaskedEditText
            android:id="@+id/reg_txt_rg"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Rg Ex.: 000000000111"
            android:inputType="text"
            />

        <com.vicmikhailau.maskededittext.MaskedEditText
            android:id="@+id/reg_txt_cpf"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="CPF Ex.: 000-000-000.00"
            android:inputType="number"
            android:maxLength="15"

            app:mask="###-###-####.##" />

        <com.vicmikhailau.maskededittext.MaskedEditText
            android:id="@+id/reg_txt_end"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Endereço Ex.: rua joao paulo 1000"
            android:inputType="text"
            />

        <com.vicmikhailau.maskededittext.MaskedEditText
            android:id="@+id/reg_txt_cep"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="CEP Ex.: 14600-000"
            android:inputType="number"
            android:maxLength="9"

            app:mask="#####-###" />

        <com.vicmikhailau.maskededittext.MaskedEditText
            android:id="@+id/reg_txt_bairro"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Bairro Ex.: centro"
            android:inputType="text"
            android:maxLength="9"
            />

        <com.vicmikhailau.maskededittext.MaskedEditText
            android:id="@+id/reg_txt_cidade"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Cidade Ex.: Parnaíba-PI"
            android:inputType="text"
            />

        <com.vicmikhailau.maskededittext.MaskedEditText
            android:id="@+id/reg_txt_duvidas"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Dúvidas sobre o curso"
            android:inputType="textMultiLine"
            />


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

            <Button
                android:id="@+id/btn_cancel"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="Cancelar" />

            <Button
                android:id="@+id/btn_save"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="Enviar Inscrição" />

        </LinearLayout>


    </LinearLayout>

</ScrollView>

2 answers

0

I don’t know what your root layout, but if it is a Relativelayout you can use the attribute android:layout_above="@+id/idDoBottomNav".

Root layout is the one that is responsible for saving your view Fragment, your Toolbar and the Bottomnavigationview.

With constraintLayout you should pay attention to its attributes, not Relativelayout. above here does not work and should be used constraintBottom_toTopOf which has the same function as above.

<android.support.constraint.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:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="br.com.pauloceami.ateliermaisprojetos.MainActivity">

    <FrameLayout
        android:id="@+id/containnersFragments"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toTopOf="@+id/navigation"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent" />

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="0dp"
        android:layout_marginStart="0dp"
        android:background="@color/colorPrimary"
        app:itemIconTint="@android:color/white"
        app:itemTextColor="@android:color/white"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:menu="@menu/navigation" />

</android.support.constraint.ConstraintLayout>

The problem here is that the View responsible for displaying the Fragment occupies the entire screen and is below the Bottomnavigationview.

You used a scroll, but did not solve because the scroll "believes" that there is nothing left to display. This can be corrected using the following approach:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:id="@+id/layouparams"
    android:layout_height="match_parent"
    android:orientation="vertical">

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

        <com.vicmikhailau.maskededittext.MaskedEditText
            android:id="@+id/reg_txt_nome"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Nome Ex.: Pedro Silva"
            android:inputType="text"
            />

        <com.vicmikhailau.maskededittext.MaskedEditText
            android:id="@+id/reg_txt_email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Email Ex.: [email protected]"
            android:inputType="textEmailAddress"
            />


        <com.vicmikhailau.maskededittext.MaskedEditText
            android:id="@+id/reg_txt_datanasc"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Data Nasc Ex.: 01/01/1980"
            android:inputType="number"
            android:maxLength="10"

            app:mask="##/##/####" />

        <com.vicmikhailau.maskededittext.MaskedEditText
            android:id="@+id/reg_txt_contato"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Contato Ex.: (16)9999-00-99"
            android:inputType="number"
            android:maxLength="14"

            app:mask="(##)####-##-##" />

        <com.vicmikhailau.maskededittext.MaskedEditText
            android:id="@+id/reg_txt_rg"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Rg Ex.: 000000000111"
            android:inputType="text"
            />

        <com.vicmikhailau.maskededittext.MaskedEditText
            android:id="@+id/reg_txt_cpf"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="CPF Ex.: 000-000-000.00"
            android:inputType="number"
            android:maxLength="15"

            app:mask="###-###-####.##" />

        <com.vicmikhailau.maskededittext.MaskedEditText
            android:id="@+id/reg_txt_end"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Endereço Ex.: rua joao paulo 1000"
            android:inputType="text"
            />

        <com.vicmikhailau.maskededittext.MaskedEditText
            android:id="@+id/reg_txt_cep"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="CEP Ex.: 14600-000"
            android:inputType="number"
            android:maxLength="9"

            app:mask="#####-###" />

        <com.vicmikhailau.maskededittext.MaskedEditText
            android:id="@+id/reg_txt_bairro"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Bairro Ex.: centro"
            android:inputType="text"
            android:maxLength="9"
            />

        <com.vicmikhailau.maskededittext.MaskedEditText
            android:id="@+id/reg_txt_cidade"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Cidade Ex.: Parnaíba-PI"
            android:inputType="text"
            />

        <com.vicmikhailau.maskededittext.MaskedEditText
            android:id="@+id/reg_txt_duvidas"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Dúvidas sobre o curso"
            android:inputType="textMultiLine"
            />


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

            <Button
                android:id="@+id/btn_cancel"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="Cancelar" />

            <Button
                android:id="@+id/btn_save"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="Enviar Inscrição" />

            <Space
                android:layout_width="0dp"
                android:layout_height="?attr/actionBarSize"/>
        </LinearLayout>
    </LinearLayout>
</ScrollView>

Just see that at the end of your layout I added the element Space which has this function of giving a "space" between views. The attribute height I used the da Actionbar because probably the Bottomnav uses the same value or something close.

With this of yours layout will be shown correctly and will not be "swallowed" by Bottomnav.


Observing: recommend using the approach with the Space, 'cause it looks cleaner.

Observation 2: The approach with Space allows the user to use Scroller normally and see the button. The first too, but the button will no longer appear to be below the Bottomnav, but rather be "cut" by it.

  • Thanks for the tip I’ll test... the other problem Imagine what it might be ? I mean that space on the right of the screen

  • It didn’t work ... I tested on mobile api 16 with android 4.1 nor appeared anything on the screen.. the views disappeared...after took and they returned.... very strange behavior.

  • that such of above ai also did not work

  • above will not work because your root layout is a Constraint layout, not a relative layout. When asking a question, let it complete.

  • @Pauloceami edited the code with your layout, take a look there ;)

0

SCREEM

as I am showing the first problem was solved with space but it did not work with attr maybe it is question of version etc etc etc... but it was solved when I put a value of 50dp in height...

The second problem is still breaking my head... already created another layout by android studio to ensure that maybe I could be doing something wrong, but no... it keeps appearing this margin on android 4 and 6 tb... Could it be some problem with Fragment ? see my layouts ...

layout with the Framelayout

form with Edittext

  • This problem with the space that appeared I solved there in my reply, take a look at the first code, which is dó main layout.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.