Это Design Link, которого я хотел достичь.Можете ли вы помочь мне с этим дизайном?
Я пытаюсь сделать это без использования Jetpack Compose. Используя Jetpack Compose, я зашел только так далеко.
Вот что я сделал на данный момент: -
Код: Выделить всё
@AndroidEntryPoint
class FragmentMenuDetail(
private val item: Item
) : BottomSheetDialogFragment() {
private var _binding: FragmentMenuDetailBinding? = null
private val binding get() = _binding!!
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = FragmentMenuDetailBinding.inflate(inflater, container, false)
return binding.root
}
@SuppressLint("SetTextI18n")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.txtFoodName.text = item.name
Glide.with(this)
.load(item.imageUrl)
.into(binding.imgFood)
binding.txtFoodDescription.text = item.description
binding.txtFoodPrice.text = "₺${item.price}"
val bottomSheet = dialog?.findViewById(com.google.android.material.R.id.design_bottom_sheet)
val behavior = BottomSheetBehavior.from(bottomSheet!!)
behavior.state = BottomSheetBehavior.STATE_COLLAPSED
behavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
override fun onStateChanged(bottomSheet: View, newState: Int) {
if (newState == BottomSheetBehavior.STATE_EXPANDED) {
// Tam ekran görünümü
bottomSheet.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT
bottomSheet.requestLayout()
}
}
override fun onSlide(bottomSheet: View, slideOffset: Float) {
val scaleFactor = 1 + (slideOffset * 0.5)
binding.imgFood.scaleX = scaleFactor.toFloat()
binding.imgFood.scaleY = scaleFactor.toFloat()
}
})
bottomSheet.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT
bottomSheet.requestLayout()
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... nt-succeed
Мобильная версия