728x90

특정 프래그먼트에서 toolbar 를 안보여주고 싶을 때 onStart()와onDestroy에서 처리해주는 방법이 있다. 

+백그라운드로 gif 이미지를 처리하려고 할 때 Glide 라이브러리를 사용 

 

class ShortsFragment : Fragment() {
    private lateinit var binding: FramentShortsBinding
    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        binding = FramentShortsBinding.inflate(inflater)
        return binding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        //글라이드 라이브러리. gif 처리 
        Glide.with(this).load(R.drawable.background).into(binding.ivBackground)
        
    }

    override fun onStart() {
        super.onStart()
        //toolbar , chipgroup 안보이게
        (activity as AppCompatActivity).supportActionBar?.hide()
        activity?.findViewById<ChipGroup>(R.id.chipGroup).let { chipGroup ->
            chipGroup?.isVisible = false // chipGroup 숨기기 
        }
    }

    override fun onDestroy() {
        //destroy 될때 다시 보여줌
        (activity as AppCompatActivity).supportActionBar?.show()
        super.onDestroy()
    }
}

toolbar가 보이는 Fragment / toolbar가 안보이는 Fragment

+ Recent posts