btnMore.setOnClickListener {
menuIconMore.visibility = View.VISIBLE
btnLess.visibility = View.VISIBLE
btnMore.visibility = View.GONE
btnPet.visibility = View.VISIBLE
}
// menuIconMore 등에 대해서는 파일 내에서 findViewById로 UI와 이미 연결해 둠.
// xml에서와 똑같이 VISIBLE,INVISIBLE,GONE이 역할을 한다.
<com.google.android.material.tabs.TabLayout
android:id="@+id/tab_store"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:itemTextColor="#1C1C1C"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="음식점" />
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="건강" />
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="생활" />
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="전체" />
</com.google.android.material.tabs.TabLayout>
tabStore.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener{
override fun onTabSelected(tab: TabLayout.Tab) {
when(tab.position){
0 -> {
storeRestaurant.visibility = View.VISIBLE
storeHealth.visibility = View.GONE
storeLife.visibility = View.GONE
storeAll.visibility = View.GONE
}
1 -> {
storeHealth.visibility = View.VISIBLE
storeRestaurant.visibility = View.GONE
storeLife.visibility = View.GONE
storeAll.visibility = View.GONE
}
2 -> {
storeHealth.visibility = View.GONE
storeRestaurant.visibility = View.GONE
storeLife.visibility = View.VISIBLE
storeAll.visibility = View.GONE
}
3 -> {
storeAll.visibility = View.VISIBLE
storeRestaurant.visibility = View.GONE
storeHealth.visibility = View.GONE
storeLife.visibility = View.GONE
}
}
}
override fun onTabUnselected(tab: TabLayout.Tab?) {
}
override fun onTabReselected(tab: TabLayout.Tab?) {
}
})
// tabStore 등에 대해서는 파일 내에서 findViewById로 UI와 이미 연결해 둠.
맨날 잘쓰던 스크롤뷰..가 원래는 잘쓰고있지 못했었나보다. 오늘 보니까 하단네비게이션에 스크롤뷰의 밑부분이 가려져서 끝까지 보이지 않았다는걸 이제 알았다. 구글링과 여러가지 방법들을 동원한 결과.. 그냥 스크롤뷰 자체에 android:paddingBottom을 주기로 했다. 근데 이게 10 20 줘서는 티도 안나고 100? 120? 정도 주니까 밑에 까지 스크롤이 되게 해줬다. 130이상부터는 하단네비게이션 위에 쪼끔 여백도 줬는데, 솔직히 뭘 기준으로 이러는지 모르겠다만 원하는 바가 나왔으니까 일단 두기로했다. 갈길이 멀어서.. 여유가 생기면 살펴보기로!
탭레이아웃이 선택되면 바뀌도록 액티비티 코틀린 파일에 작성했을 때, 코드엔 전혀 문제가 없는 것 같은데도 Null예외가 떴다. 아예 액티비티가 넘어가지 않았다. 그래서 알음알음 세이프콜도 써보고.. 지양해야한다던 !!도 써보고.. 했는데도 도통 바뀌는게 없어서, 로그캣에서 내 코드에 문제발생지점 찍어준 곳부터 다시 찬찬히 봤는데, 내가.. findViewById를 엉뚱한 것을 걸어둬서 값을 못 받아오는거였다.! 내 나름대로 구분하기 위해서 노력한 아이디 분류였는데도, 다 그게 그거 같으니까 헷갈린다. 열받긴한데.. 찾아서 너무 다행이다. 진짜 몇시간짜리였을 뻔.. 이런 오타?오류같은건 너무 무섭다.