밍쯔와 안작고 안귀여운 에러들🖤

[Android/Java] 중첩 RecyclerView의 이미지 clip 본문

Develop/Android | iOS

[Android/Java] 중첩 RecyclerView의 이미지 clip

밍쯔 2022. 6. 8. 17:23

[상황]

- RecyclerView 안에 RecyclerView가 있음.

- 내부 recyclerview의 바인딩된 이미지가 외부 recyclerview 틀 밖으로 튀어나옴. (모서리)

 

[해결]

- 외부 recyclerview의 BindViewHolder에 Clip하는 코드 추가

@Override
    public void onBindViewHolder(OneClickViewHolder holder, int index) {
        ...
        holder.itemView.setOutlineProvider(ViewOutlineProvider.BACKGROUND);
        holder.itemView.setClipToOutline(true);
        ...
    }

 

[참고]

https://stackoverflow.com/questions/5574212/android-view-clipping

 

Android View Clipping

Is there any way to define the clip region of a ViewGroup in android (Honeycomb)? For example, I have a ListView with an image background that has rounded corners. As I scroll through the list, the

stackoverflow.com

https://stackoverflow.com/questions/50466396/recyclerview-dont-clip-item-in-the-corner

 

RecyclerView don't clip item in the corner

I want to make recyclerView round corner but seem like if the child item has background color, it will cover to the recyclerView and couldn't be clipped. Here is the design If I remove the background

stackoverflow.com