Problem with BottonNavigationView

0

Asyoucansee,I'mhavingalayoutproblemwiththisformonAndroid,thisformisopenedinsideafragmentnormallywhereI'mgoingtosendthedata.

1-Tomysurprise,EditTextdoesnotexpandtotheentirescreen.IalreadytriedusingLayoutParamssettingmatchparentbutnothinghappened...

2-ButtonsarehidingbehindBottonNavigationView,alreadytriedtoputascrollviewtherebutitdoesnotgetoutofthere...

ThiscomponentBottonNavigationhastobefixedonthescreenbecauseIdonotwantittohidewiththeBehaviorfunction...asithappenshere BottonNavigation

Would anyone have any tips for trying to fit this form correctly or some help from the 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>
    
asked by anonymous 11.01.2018 / 02:44

2 answers

0

AsI'mshowingthefirstproblemwassolvedwithspacebutitdidnotworkwithattrmaybeit'saversionissueetcetc...butitwassolvedwhenIputavalueof50dpinheight...

Thesecondproblemisstillbreakingmyhead...IhavealreadycreatedanotherlayoutbyandroidstudiotomakesurethatmaybeIcouldbedoingsomethingwrong,butno...itkeepsappearingthatmarginonandroid4and6tb...canitbeaproblemwithfragment?seemylayouts...

Layout with FrameLayout

form with EditText

    
11.01.2018 / 06:46
0

I do not know what your root layout , but if it's a RelativeLayout you can use the android:layout_above="@+id/idDoBottomNav" attribute.

The root layout is the one that is responsible for saving the view of your Fragment , your Toolbar and BottomNavigationView p>

With constraintLayout you should be aware of its attributes, not of RelativeLayout. The above here does not work and should use 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 View that is responsible for displaying Fragment takes up the entire screen under the BottomNavigationView .

You used a scroll, but it did not work because 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 notice that at the end of your layout I added the Space element that has this function to give a "space" between views . The height attribute I used the ActionBar attribute because BottomNav probably uses the same value or something close.

With this your layout will be displayed correctly and will not be "swallowed" by BottomNav .

Note : I recommend using the Space approach as it seems to me to be cleaner.

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

    
11.01.2018 / 02:57