Office Hours — Today, November 20

Sunday, November 18

Nov 20
8:55 AM
Mark M.
has entered the room
Mark M.
turned on guest access
9:15 AM
ndrocchietto_ivano
has entered the room
ndrocchietto_ivano
HI mark
Mark M.
hello, Ivano!
how can I help you today?
ndrocchietto_ivano
I have to resolve a legacy code problem
I have a TabLayout with two different tabs. The initial Tab shows a CardView and want to place the @id/logo (the last item in the xml file) just below this Card. Namely if the user search for a term, I made the CardView invisible programmatically, and a RecyclerView will populate the screen below the RecyclerView and after the Recycler View will appear the logo, if instead the user presses the second tab, the RecyclerView will populate all the screen
View paste (114 more lines)
 <?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/cardViewBackground">

<android.support.design.widget.TabLayout
    android:id="@+id/address_filter_tl"
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:layout_gravity="start"
    android:background="@color/colorPrimary"
    app:layout_constraintStart_toStartOf="parent"
...
9:20 AM
ndrocchietto_ivano
and this is the include file
View paste (6 more lines)
<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:clipToPadding="false"
    android:layout_height="wrap_content">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/addresses_rv"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:paddingTop="0dp"
        android:paddingBottom="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
...
Mark M.
what is your question?
ndrocchietto_ivano
how can I have on the first tab
the google logo
behind the recyclerView
the problem is that when the tab starts :
View paste
    private fun TabLayout.bindTabLayout() {

        RxTabLayout.selectionEvents(this)
            .map {
                if (selectedTabPosition == 0) SEARCHED_LOCATION
                else SAVED_LOCATION
            }
            .subscribe {
                viewModel.scopeFilter.accept(it)
            }
            .addTo(disposeBag)

    }
and is selected SEARCHED LOCATION, I have also the cardView
that become invisible as soon as the user write in the search field where the layout is wrapped
9:25 AM
ndrocchietto_ivano
I know is really difficult to understand
and the view do too many things
Mark M.
by "behind the recyclerView", are you referring to the addresses_rv RecyclerView?
ndrocchietto_ivano
correct
Mark M.
and by "behind", you mean on the Z axis?
ndrocchietto_ivano
no
I mean the google logo, basically the last attribute in the main xml file indicated as AppCompactView
and for behind recycler view
I mean below the recyclerView
basically you have this search activity, and initially you have a card view with your own location, and the logo of google below
Mark M.
it seems like @id/logo already is below @id/search_results_cv on the Y axis
ndrocchietto_ivano
if the user makes a search then the cardView with your own location disappears and is loaded the recyclerView via <include showing at the end of the research the google logo
finally if the user touch the second tab address, is opened a catalogue of adresses
via the SAME recyclerView
Mark M.
search_results_cv has app:layout_constraintBottom_toBottomOf="parent", so it will stretch to the bottom of the available space
ndrocchietto_ivano
and in this second tab the google logo have to disappear
9:30 AM
ndrocchietto_ivano
this is correct in the second tab
Mark M.
logo is trying to position itself below search_results_cv, which will not work, as there is no space there
ndrocchietto_ivano
and also on the first one
this is correct
I am impressed you understood this use case
Mark M.
I disagree that I understand the use case
ndrocchietto_ivano
ahahah
Mark M.
I am simply trying to make sense of your layout
ndrocchietto_ivano
ok
the problem is that should have two different behaviours depending by the tab clicked
maybe I should do a wild refactoring
Mark M.
either have two different ImageViews or change the layout rules for the existing ImageView at runtime, I guess
ndrocchietto_ivano
ok thanks
I should pass in <include
in one case android:layout_height="wrap"
app:layout_constraintBottom_toBottomOf="parent"/>
and in another
View paste
        android:layout_height="wrap"
is that possible programmatically?
Mark M.
you can change the rules associated with a child of ConstraintLayout using a ConstraintSet, if that is what you mean
9:35 AM
ndrocchietto_ivano
yes
9:35 AM
ndrocchietto_ivano
but the constant layout I want to change is inside this include
Mark M.
at runtime, that should not matter much
<include> is a layout inflater thing
ndrocchietto_ivano
and I need to change also the heigt
I see
Mark M.
ConstraintSet also lets you control the height and width rules
ndrocchietto_ivano
I see thank you for the hint
I am gonna work on that
9:55 AM
Mark M.
any last questions?
10:00 AM
ndrocchietto_ivano
no fine\
have a nice afternoon
learned a lot today
this is what matters
Mark M.
OK, then, that's a wrap for today's chat
the next chat is tomorrow at 7:30pm US Eastern
have a pleasant day!
ndrocchietto_ivano
has left the room
Mark M.
turned off guest access

Sunday, November 18

 

Office Hours

People in this transcript

  • Mark Murphy
  • ndrocchietto_ivano