1

enter image description here

My problem is similar to this one:

Android - Align view center to bottom of other view

But id differs in a significant detail. I don't want to center the view with the end of the RecyclerView, but with the center of it's last child view. So I can't just use:

app:layout_constraintStart_toEndOf="@+id/recycler_view"
app:layout_constraintEnd_toEndOf="@+id/recycler_view"

Would there be a solution for this case?

user677767
  • 203
  • 3
  • 10
  • probably you'll have to use recyclerview with different itemTypes, check this link, might help https://stackoverflow.com/a/26245463/2931124 – ked May 19 '21 at 15:32
  • You did say ConstraintLayout, so the question is the RecyclerView or horizontal or vertical orientation.? – Cheticamp May 19 '21 at 17:38
  • @Cheticamp Horizontal orientation – user677767 May 19 '21 at 19:41
  • So the RecyclerView items slide left and right. What happens to the custom view when that top/right item moves? Does it move with it or does it stay? (I'm assuming it stays.) – Cheticamp May 19 '21 at 22:54
  • If you know something definite about the relationship of the width of the items to the width of the RecyclerView such as "the width of the RecyclerView is always four times the width of each item", then you could probably do something in XML. If not, then you will need to do some coding to place a guideline or something similar. – Cheticamp May 19 '21 at 23:09

1 Answers1

0

Just put the last view that you want at center inside the recycle_list_item.xml because here you can align the lastView vertically center . then do some logic in onBindViewHolder()

 @Override
    public void onBindViewHolder(@NonNull BusStopViewHolder holder, int position) {
       
        if(position==viewList.size()-1){
            
         
            holder.lastView.setVisibility(View.Visible);

        }
       else  holder.lastView.setVisibility(View.Gone);}
androidLearner
  • 1,654
  • 1
  • 7
  • 13