커스텀 리스트뷰를 만들고 있습니다. 리스트뷰 모양을 모서리에는 둥글게 만들고, 리스트뷰 사이에 눈으로 보기에 어느정도 간격이 있도록 만들고 있습니다.
리스트 1개에 대한 레이아웃을 따로 만들고, 모서리 라운드 모양을 주기 위해 drawable 파일을 생성해서 background로 사용하였습니다.
리스트 background
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFF3F3F3" />
<padding
android:left="1dp"
android:right="1dp"
android:top="1dp"
android:bottom="1dp"/>
<corners android:radius="7dp"/>
</shape>
리스트 1개의 레이아웃
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="85dp"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background_ble_list"
//생략
android:layout_margin="5dp">
<LinearLayout
android:id="@+id/text_device"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
//생략
app:layout_constraintEnd_toEndOf="parent">
<TextView
//생략
/>
<TextView
//생략
/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
제가 원하는건 list 클릭했을 때
android:background="@drawable/background_ble_list"
이 background 부분을 색을 변경하는 건데요. listselector 같은 경우는 그 뒤의 배경이 변경되더라구요... 모양은 처음 코드처럼 저렇게 살리고 싶고, 리스트 클릭시에 그 모양이 나타나는 안쪽 부분만 색을 바꾸고 싶은데, 어떻게 해야할까요? 아예 다른 방법이 있을까요?