Progress bar show under Button - android

Android studio 3.1
minSdkVersion 21
Here my layout xml:
<?xml version="1.0" encoding="utf-8"?>
<layout 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">
<data>
<variable
name="handler"
type="md.dotfinance.tm.android.ui.activity.AddTraderActivity" />
</data>
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/common_gray_color_bg">
<include
android:id="#+id/jsonViewToolBar"
layout="#layout/tool_bar"
android:title='#{#string/add_trader}'
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/baseTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="#dimen/default_margin"
android:layout_marginEnd="8dp"
android:text="#string/base"
android:textSize="13sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/jsonViewToolBar" />
<EditText
android:id="#+id/baseEditText"
style="#style/textViewOneLine"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="#+id/baseTextView"
app:layout_constraintStart_toStartOf="#+id/baseTextView"
app:layout_constraintTop_toBottomOf="#+id/baseTextView" />
<TextView
android:id="#+id/quoteTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/default_margin"
android:text="#string/quote"
android:textSize="13sp"
app:layout_constraintEnd_toEndOf="#+id/baseTextView"
app:layout_constraintStart_toStartOf="#+id/baseTextView"
app:layout_constraintTop_toBottomOf="#+id/baseEditText" />
<EditText
android:id="#+id/quoteEditText"
style="#style/textViewOneLine"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="13sp"
app:layout_constraintEnd_toEndOf="#+id/baseTextView"
app:layout_constraintStart_toStartOf="#+id/baseTextView"
app:layout_constraintTop_toBottomOf="#+id/quoteTextView" />
<Button
android:id="#+id/startButton"
android:layout_width="0dp"
android:layout_height="#dimen/min_height"
android:layout_marginTop="#dimen/default_margin"
android:layout_marginBottom="#dimen/default_margin"
android:background="#color/button_gray"
android:text="#string/start"
app:layout_constraintEnd_toEndOf="#+id/baseTextView"
app:layout_constraintStart_toStartOf="#+id/baseTextView"
app:layout_constraintTop_toBottomOf="#+id/quoteEditText" />
<include
layout="#layout/progress_bar_layout"
android:visibility="gone" />
</android.support.constraint.ConstraintLayout>
</layout>
Here my progress_bar_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/containerProgressBarLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#4777"
android:clickable="true"
android:focusable="true">
<ProgressBar
android:id="#+id/progressBar"
style="?android:attr/progressBarStyle"
android:layout_width="48dp"
android:layout_height="48dp"
android:indeterminateTint="#color/colorPrimary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
But when I start app the progress bar is UNDER button.
But I need over button.
How I can do this?

Try to use
of
android.support.constraint.ConstraintLayout
and add
android:elevation="30dp"
to the RelativeLayout tag

The best way to do this is to hide the progress bar or make it's visibility="gone". Make sure you give it an ID so you can invoke it and hide the other layout with buttons and text views. Then show the progress bar when you process a certain request. Make it invisible!!!

Try that
<?xml version="1.0" encoding="utf-8"?>
<layout 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">
<data>
<variable
name="handler"
type="md.dotfinance.tm.android.ui.activity.AddTraderActivity" />
</data>
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
layout="#layout/progress_bar_layout"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/common_gray_color_bg">
<include
android:id="#+id/jsonViewToolBar"
layout="#layout/tool_bar"
android:title='#{#string/add_trader}'
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/baseTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="#dimen/default_margin"
android:layout_marginEnd="8dp"
android:text="#string/base"
android:textSize="13sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/jsonViewToolBar" />
<EditText
android:id="#+id/baseEditText"
style="#style/textViewOneLine"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="#+id/baseTextView"
app:layout_constraintStart_toStartOf="#+id/baseTextView"
app:layout_constraintTop_toBottomOf="#+id/baseTextView" />
<TextView
android:id="#+id/quoteTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/default_margin"
android:text="#string/quote"
android:textSize="13sp"
app:layout_constraintEnd_toEndOf="#+id/baseTextView"
app:layout_constraintStart_toStartOf="#+id/baseTextView"
app:layout_constraintTop_toBottomOf="#+id/baseEditText" />
<EditText
android:id="#+id/quoteEditText"
style="#style/textViewOneLine"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="13sp"
app:layout_constraintEnd_toEndOf="#+id/baseTextView"
app:layout_constraintStart_toStartOf="#+id/baseTextView"
app:layout_constraintTop_toBottomOf="#+id/quoteTextView" />
<Button
android:id="#+id/startButton"
android:layout_width="0dp"
android:layout_height="#dimen/min_height"
android:layout_marginTop="#dimen/default_margin"
android:layout_marginBottom="#dimen/default_margin"
android:background="#color/button_gray"
android:text="#string/start"
app:layout_constraintEnd_toEndOf="#+id/baseTextView"
app:layout_constraintStart_toStartOf="#+id/baseTextView"
app:layout_constraintTop_toBottomOf="#+id/quoteEditText" />
</android.support.constraint.ConstraintLayout>
</layout>

Related

How to fill the rest of the screen with RecyclerVeiw?

In the image below you can see the RecyclerView extends below my screen. This is the reason why I can't see the last item. I want only my RecyclerView to be scrollable.
Can I solve this with the xml only?
This is my_fragment.xml.
<?xml version="1.0" encoding="utf-8"?>
<layout 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"
tools:context=".screens.mijnhuis.HuisFragment">
<data>
<import type="android.view.View"/>
<import type="android.text.TextUtils"/>
<variable
name="varName"
type="be.vives.ti.summatieve.screens.mijnhuis.HuisVM"/>
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical">
<TextView
android:id="#+id/adres"
style="#style/MainText"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:layout_marginTop="50dp"
android:text='#{TextUtils.isEmpty(varName.huis.straat) ? "U heeft nog geen adres ingesgteld":#string/adres(varName.huis.straat, varName.huis.nummer, varName.huis.gemeente, varName.huis.postcode)}'
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/button2"
style="#style/btn"
android:layout_marginStart="20dp"
android:onClick="#{() -> varName.btnNavToEditHuis()}"
android:text="#string/edit"
app:layout_constraintStart_toEndOf="#+id/button3"
app:layout_constraintTop_toBottomOf="#+id/adres" />
<Button
android:id="#+id/button3"
style="#style/btn"
android:layout_marginEnd="110dp"
android:onClick="#{() -> varName.btnNavToAdd()}"
android:text="#string/addDak"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/button2" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/list"
android:name="be.vives.ti.summatieve.HuisFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
app:layoutManager="LinearLayoutManager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/button3"
tools:context=".screens.mijnHuis.HuisFragment"
tools:listitem="#layout/detail_dak" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
In this image, you can see that my RecyclerView extends under my screen.
Image
You are missing a bottom constraint. Try setting like this:
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/list"
android:name="be.vives.ti.summatieve.HuisFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
app:layoutManager="LinearLayoutManager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/button3"
app:layout_constraintBottom_toBottomOf="parent"
tools:context=".screens.mijnHuis.HuisFragment"
tools:listitem="#layout/detail_dak" />
Welcome Bjop, try this:
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/list"
android:name="be.vives.ti.summatieve.HuisFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
app:layoutManager="LinearLayoutManager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/button3"
tools:context=".screens.mijnHuis.HuisFragment"
tools:listitem="#layout/detail_dak" />

BottomAppBar navigation items are not clickable because of NestedScrollView

My app bar is located below my scroll view and therefore the items are not clickable
My scroll view should stop just above my BottomAppBar
how to do that ?
And how to make the BottomAppBar always visible
Useless text for my post to pass, very restrictive this rule
The story of a cat who wanted to eat the dog's bowl.
I hope there is enough unnecessary text
Layout
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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">
<com.google.android.material.bottomappbar.BottomAppBar
android:id="#+id/bottomAppBar"
style="#style/Widget.MaterialComponents.BottomAppBar.Colored"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:menu="#menu/menu_show_bottom"
app:navigationIcon="#drawable/ic_action_home_blank" />
<include
android:id="#+id/contentScroll"
layout="#layout/content_scrolling" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/btnAddClean"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_anchor="#id/bottomAppBar"
app:layout_anchorGravity="bottom|end"
app:srcCompat="#drawable/ic_action_clean" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Content scrolled
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView 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"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:showIn="#layout/fragment_avaloir_show">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/rueTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="#style/TextAppearance.MaterialComponents.Headline5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Rue des jolis bois " />
<ImageView
android:id="#+id/avaloirImageView"
android:layout_width="263dp"
android:layout_height="350dp"
android:contentDescription="#string/content_description"
android:src="#drawable/aval2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/rueTextView" />
<TextView
android:id="#+id/coordinatesTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/avaloirImageView"
tools:text="50.235621, 5.23658" />
<com.google.android.gms.maps.MapView
android:id="#+id/mapView"
android:layout_width="match_parent"
android:layout_height="350dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/coordinatesTextView" />
<TextView
android:id="#+id/titreDatesNettoyageTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:text="#string/title_dates_nettoyage"
android:textAppearance="#style/TextAppearance.MaterialComponents.Headline5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/mapView" />
<View
android:id="#+id/dividerView"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="16dp"
android:background="#color/colorPrimaryDark"
app:layout_constraintBottom_toBottomOf="#+id/titreDatesNettoyageTextView" />
<TextView
android:id="#+id/datesTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/dividerView"
tools:text="10 avril 2019" />
<TextView
android:id="#+id/titreCommentairesTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:text="#string/title_commentaires"
android:textAppearance="#style/TextAppearance.MaterialComponents.Headline5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/datesTextView" />
<View
android:id="#+id/commentDividerView"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="16dp"
android:background="#color/colorPrimaryDark"
app:layout_constraintBottom_toBottomOf="#+id/titreCommentairesTextView" />
<TextView
android:id="#+id/commentairesTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/commentDividerView"
tools:text="Il est cassé il faut le remplacer" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
finally I added a linearLayout
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include
android:id="#+id/contentScroll"
layout="#layout/content_scrolling" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<com.google.android.material.bottomappbar.BottomAppBar
android:id="#+id/bottomAppBar"
style="#style/Widget.MaterialComponents.BottomAppBar.Colored"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:menu="#menu/menu_show_bottom"
app:navigationIcon="#drawable/ic_action_home_blank" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/btnAddClean"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_anchor="#id/bottomAppBar"
app:srcCompat="#drawable/ic_action_clean" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/rueTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="#style/TextAppearance.MaterialComponents.Headline5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Rue des jolis bois " />
<ImageView
android:id="#+id/avaloirImageView"
android:layout_width="263dp"
android:layout_height="350dp"
android:contentDescription="#string/content_description"
android:src="#drawable/aval2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/rueTextView" />
<TextView
android:id="#+id/coordinatesTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/avaloirImageView"
tools:text="50.235621, 5.23658" />
<com.google.android.gms.maps.MapView
android:id="#+id/mapView"
android:layout_width="match_parent"
android:layout_height="350dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/coordinatesTextView" />
<TextView
android:id="#+id/titreDatesNettoyageTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:text="#string/title_dates_nettoyage"
android:textAppearance="#style/TextAppearance.MaterialComponents.Headline5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/mapView" />
<View
android:id="#+id/dividerView"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="16dp"
android:background="#color/colorPrimaryDark"
app:layout_constraintBottom_toBottomOf="#+id/titreDatesNettoyageTextView" />
<TextView
android:id="#+id/datesTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/dividerView"
tools:text="10 avril 2019" />
<TextView
android:id="#+id/titreCommentairesTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:text="#string/title_commentaires"
android:textAppearance="#style/TextAppearance.MaterialComponents.Headline5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/datesTextView" />
<View
android:id="#+id/commentDividerView"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="16dp"
android:background="#color/colorPrimaryDark"
app:layout_constraintBottom_toBottomOf="#+id/titreCommentairesTextView" />
<TextView
android:id="#+id/commentairesTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/commentDividerView"
tools:text="Il est cassé il faut le remplacer" />
</androidx.constraintlayout.widget.ConstraintLayout>

Bottom Space on layouts Android

I have a parent constraint layout and i am getting bottom Space on each and Check Image U can see space at bottom even layout constraints are attach to bottom of parent every layout. However layout I have developed before are all working fine. Below is XML for one of my layouts.
You can see I have attached Constraints to bottom of parent but still I am getting this issue.
Please notice I have changed it to linear as well still the result is same. One strange thing is on Emulator its working fine.
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:bind="http://schemas.android.com/tools">
<data>
<import type="android.view.View" />
<variable
name="handler"
type="com.schoolber.handler.ChatEventhandlers" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
>
<include
android:id="#+id/toolbar_tag"
layout="#layout/chat_main_toolbar_layout"
android:layout_width="0dp"
android:layout_height="#dimen/action_bar_height"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
bind:handler="#{handler}" />
<!-- <androidx.appcompat.widget.Toolbar-->
<!-- android:id="#+id/toolbar"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="#dimen/action_bar_height"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent"-->
<!-- />-->
<View
android:id="#+id/greyPortionView"
android:layout_width="0dp"
android:layout_height="1dp"
android:background="#color/white_four"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/toolbar_tag" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/chatInboxList"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="1dp"
android:background="#null"
app:layout_constraintBottom_toTopOf="#+id/greyPortionViewSecond"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/greyPortionView" />
<TextView
android:id="#+id/noRecentTV"
android:layout_width="0dp"
android:layout_height="48dp"
android:textSize="10sp"
android:gravity="center_vertical"
android:paddingStart="32dp"
android:background="#color/white_seven"
app:layout_constraintTop_toBottomOf="#id/toolbar_tag"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:textColor="#color/brownish_grey"
android:letterSpacing="0.03"
android:lineSpacingExtra="3sp"
android:text="No Recent Chat Found"
/>
<ImageView
android:id="#+id/add_chat_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="#drawable/ic_add_icon"
android:layout_margin="16dp"
android:background="#drawable/circle_shadow"
android:elevation="4dp"
android:translationZ="4dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="#+id/greyPortionViewSecond"
/>
<View
android:id="#+id/greyPortionViewSecond"
android:layout_width="0dp"
android:layout_height="1dp"
android:background="#color/white_four"
android:layout_marginBottom="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="#+id/fab_messgae" />
<ImageView
android:id="#+id/fab_messgae"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="#{() -> handler.searchUser()}"
android:scaleType="fitXY"
app:layout_constraintBottom_toTopOf="#+id/ic_chat"
app:backgroundTint="#android:color/transparent"
app:layout_constraintStart_toEndOf="#+id/ic_chat"
app:layout_constraintEnd_toStartOf="#+id/ic_chat"
app:srcCompat="#drawable/ic_menuchat_icon" />
<TextView
android:id="#+id/ic_chat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10sp"
android:layout_marginBottom="16dp"
android:textColor="#color/aqua_marine"
android:letterSpacing="0.03"
android:lineSpacingExtra="-4sp"
android:text="#string/chat"
app:layout_constraintEnd_toStartOf="#id/ic_profile_tv"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:gravity="center_horizontal"
/>
<ImageView
android:id="#+id/fab_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="#{() -> handler.searchUser()}"
android:scaleType="fitXY"
app:layout_constraintBottom_toTopOf="#+id/ic_profile_tv"
app:backgroundTint="#android:color/transparent"
app:layout_constraintStart_toEndOf="#+id/ic_profile_tv"
app:layout_constraintEnd_toStartOf="#+id/ic_profile_tv"
app:srcCompat="#drawable/ic_menucontacts_icon" />
<TextView
android:id="#+id/ic_profile_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10sp"
android:layout_marginBottom="16dp"
android:text="#string/contacts"
android:textColor="#000000"
android:letterSpacing="0.03"
android:lineSpacingExtra="-4sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="#id/ic_chat"
android:gravity="center_horizontal"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

how to fix this category Layout Problems in Android App

I have a problem with the Category Layout in my App. The problem is that the next category starts in the next line. I want to show it a mixed layout. Not like another category will show below that category. Please help me to fix this issue. I have searched on the internet but don't know how to fix it.
item_category_list_adapter.xml
<?xml version="1.0" encoding="utf-8"?>
<layout 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">
<data>
<variable
name="allWallpaperByCategory"
type="com.panaceasoft.pswallpaper.viewobject.Category" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/constraintLayout3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="#+id/itemImageView"
android:layout_width="0dp"
android:layout_height="0dp"
android:contentDescription="No Image"
android:scaleType="centerCrop"
app:imageUrl="#{allWallpaperByCategory.default_photo.img_path}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="HardcodedText"
tools:srcCompat="#drawable/app_icon" />
<View
android:id="#+id/view52"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#drawable/black_alpha_50"
app:layout_constraintBottom_toBottomOf="#+id/itemImageView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/itemImageView"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="#+id/productCountTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:text="#string/category__30wallpaper"
android:textAlignment="viewStart"
android:textColor="#color/md_grey_400"
android:textSize="#dimen/font_body_size"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/categoryNameTextView"
tools:ignore="MissingConstraints" />
<TextView
android:id="#+id/categoryNameTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:textAlignment="viewStart"
android:textColor="#color/md_grey_300"
android:textSize="#dimen/font_h5_size"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/view52"
tools:ignore="MissingConstraints"
tools:text="20 Category" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
mybe you can do this in your item xml n in you recyclerview use layout manager gridview 2 coloums
Like this
<?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="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:padding="5dp"
android:text="Demo Text" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:padding="5dp"
android:text="Demo Text" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:padding="5dp"
android:text="Demo Text 2" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:padding="5dp"
android:text="Demo Text" />
</LinearLayout>
</LinearLayout>
You have to generate custom layout using canvas.
Please go through the links
https://developer.android.com/training/custom-views/custom-drawing
https://medium.com/over-engineering/getting-started-with-drawing-on-the-android-canvas-621cf512f4c7
https://medium.com/mindorks/how-to-create-custom-views-141dc0570e57

How to adjust constraint layout to scroll view to fit all screen?

I have problem in the bottom layout where my constraint layout does not fill the scroll view entirely(blank space bellow). This is the image evidence of the problem.
In this case I want the gray background to fill that white space below. I tried match parent in everything but it does not work.
This is my xml file that belongs to the layout I uploaded
<?xml version="1.0" encoding="utf-8"?>
<layout 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/layout">
<data>
<variable
name="viewModel"
type="com.repsol.repsolmove.ui.login.LoginViewModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.core.widget.NestedScrollView
android:id="#+id/scrolView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/imageView"
android:layout_width="174dp"
android:layout_height="70dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="3dp"
android:src="#drawable/ic_img_logo_repsolmove"
app:layout_constraintBottom_toTopOf="#+id/imageBottomMargin"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.repsol.repsolmove.ui.widgets.RepsolInputLayout
android:id="#+id/login"
android:layout_width="0dp"
android:layout_height="105dp"
android:layout_marginTop="30dp"
app:errorText="#string/invalid_card_number"
app:layout_constraintEnd_toStartOf="#+id/marginEnd"
app:layout_constraintStart_toStartOf="#+id/marginStart"
app:layout_constraintTop_toBottomOf="#+id/imageView"
app:titleText="#string/login_title" />
<com.repsol.repsolmove.ui.widgets.RepsolInputLayout
android:id="#+id/password"
android:layout_width="0dp"
android:layout_height="105dp"
app:errorText="#string/invalid_password"
app:isPassword="true"
app:layout_constraintEnd_toStartOf="#+id/marginEnd"
app:layout_constraintStart_toStartOf="#+id/marginStart"
app:layout_constraintTop_toBottomOf="#+id/login"
app:titleText="#string/password_title" />
<TextView
android:id="#+id/newPassword"
style="#style/RepsolText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:layout_marginEnd="8dp"
android:fontFamily="#font/repsol_regular"
android:text="#string/new_password"
android:textSize="16dp"
app:layout_constraintEnd_toStartOf="#+id/marginEnd"
app:layout_constraintTop_toBottomOf="#+id/password" />
<Button
android:id="#+id/btnLogin"
android:layout_width="228dp"
android:layout_height="50dp"
android:layout_marginStart="8dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="8dp"
android:background="#drawable/shape_rounded_fill_rectangle"
android:fontFamily="#font/repsol_regular"
android:text="#string/login"
android:textAllCaps="false"
android:textColor="#android:color/white"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/newPassword" />
<Button
android:id="#+id/btnJoin"
android:layout_width="0dp"
android:layout_height="51dp"
android:layout_marginStart="8dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="32dp"
android:background="#drawable/shape_rounded_rectangle"
android:fontFamily="#font/repsol_regular"
android:text="#string/join"
android:textAllCaps="false"
android:textColor="#color/colorPrimaryDark"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/btnNologin"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="#+id/marginStart"
app:layout_constraintTop_toBottomOf="#+id/btnLogin"
app:layout_constraintVertical_bias="0.75" />
<Button
android:id="#+id/btnNologin"
android:layout_width="0dp"
android:layout_height="51dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="32dp"
android:background="#drawable/shape_rounded_no_stroke_rectangle"
android:fontFamily="#font/repsol_regular"
android:text="#string/enter_without_login"
android:textAllCaps="false"
android:textColor="#color/colorPrimaryDark"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/marginEnd"
app:layout_constraintStart_toEndOf="#+id/btnJoin"
app:layout_constraintTop_toBottomOf="#+id/btnLogin"
app:layout_constraintVertical_bias="0.75" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/imageBottomMargin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.30" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/marginStart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.10" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/marginEnd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.90" />
<com.repsol.repsolmove.ui.widgets.RepsolDialog
android:id="#+id/dialog"
android:layout_width="match_parent"
android:layout_height="0dp"
android:elevation="10dp"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<include
android:id="#+id/loading"
layout="#layout/loading"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
Add this attribute to your NestScrollView element in xml file
android:fillViewport="true"

Categories

Resources