🔥TIL🔥스파르타 | 사과마켓 정리

hyihyi·2024년 1월 11일
0

TIL

목록 보기
32/69
post-thumbnail

1.이미지 라운드 처리

여러가지 방법이 있다.
여기서는 라이브러리를 안 쓰는 방법을 사용함

CardView로 감싸고 내부 옵션이 cardCornerRadius로 깎으면 됨

-편하게 라운드 처리할 수 있는 방법
<androidx.cardview.widget.CardView
android:id="@+id/card_item_image"
android:layout_width="110dp"
android:layout_height="110dp"
app:cardCornerRadius="8dp"
app:cardElevation="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

    <ImageView
        android:id="@+id/iv_item_image"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center_vertical"
        android:adjustViewBounds="true"
        android:scaleType="centerCrop"
        android:src="@drawable/sample1"/>
    </androidx.cardview.widget.CardView>

2. 글자 밑줄 넣기

그 중 가장 편한 방법은 string.xml에 <u>태그를 주면 된다.

3.intent의 key 값도 미리 맞춰놓자

Constans Object를 하나 만들어서 파일로 따로 뺌

with(binding.rvMain){
            this@with.adapter = itemAdapter
            layoutManager = LinearLayoutManager(this@MainActivity)
        }

???????????????혼자 해보기 : 아직 with이 안 익숙한데 with을 활용한 예제 코드를 짜보자!

4.뒤로가기 버튼을 눌렸을 때/back 버튼 눌렀을 때

둘 다 처리를 해주기 위해 exit()함수로 분리함

5. 아이템 클릭 부분

2가지가 있음
1.어댑터 내에서도 클릭을 처리할 수도 있고
2.인터페이스를 통해 클릭 이벤트를 메인 액티비티로 넘겨줌

인터페이스의 클릭 이벤트가 발생하면 Main의 함수가 콜백됨

onBindViewHolder에서 해당 아이템의 클릭 이벤트를 감지하면 Main으로 콜백이 됨

Detail 페이지에서 하트가 눌려졌을 때 Main 페이지에서 바껴야 하기 때문에 어댑터에서 직접 onClick을 처리하면 안되고 인터페이스가 필요했던 것.
그래서 일반적인 intent를 보내는 것이 아니고 activityResultLauncher를 보내야 함

??????????????????? activityResultLauncher도 다시 정리하자

binding.rvMain.canScrollVertically(-1)
->스크롤이 가장 위에 가 있는지

6. 이미지 겹칠 때

Detail화면에서 맨 위에 있는 화살표 이미지뷰는 스크롤되지 않게 하려면 스크롤뷰 태그 밑에 놔두면 보인다.(스크롤뷰 태그 위에 있었을 때는 가려서 안 보였음)

profile
자유롭게 쓴 나의 자유로운 Development voyage⛵

0개의 댓글