
두가지 문제가 있습니다.
첫번째는 gone상태에서 롱클릭을 할시에 애니메이션 효과가 나오지 않습니다. 그후 visible 상태에서 다시 롱클릭을 하면 animation이 나옵니다.
두번째로는 animation 효과가 모든 item에서 보이지 않습니다.
일단 animation 구현 코드와 롱클릭시 checkbox visible에관한 코드는 아래와 같습니다
class ItemMemoListViewHolder(itemView: View?): RecyclerView.ViewHolder(itemView!!) {
val title = itemView?.findViewById<TextView>(R.id.memo_list_item_title)
val date = itemView?.findViewById<TextView>(R.id.memo_list_item_date)
val contents = itemView?.findViewById<TextView>(R.id.memo_list_item_contents)
val check = itemView?.findViewById<CheckBox>(R.id.memo_list_item_check)
fun bind(memo: Memo) {
title?.text = memo.title
date?.text = memo.currentDate
contents?.text = memo.contents
if(memo.isVisibility){
val anim = TranslateAnimation(-check!!.width.toFloat(),0f,0f,0f)
anim.duration = 400
anim.fillAfter = true
title!!.animation = anim
date!!.animation = anim
check!!.animation = anim
check!!.visibility = View.VISIBLE
}
else{
check?.visibility = View.GONE
}
}
}
holder.itemView.setOnLongClickListener(object : View.OnLongClickListener{
override fun onLongClick(v: View?): Boolean {
for(index in 0..data.size-1){
data[index].isVisibility = true
}
notifyDataSetChanged()
return true
}
})
memo 라는 데이터클래스 안에 isVisiblity라는 boolean 타입의 변수로 checkbox를 제어하는 방법으로 구현했습니다.
만약 해결 방법이 있다면 조언부탁바랍니다!!
혹은 animation 구현방법 자체가 비효율적이거나 잘못됐다면 구현 방향이라도 조언해주시면 감사하겠습니다!