По отдельности первые два представления отображаются так, как должны, но когда я прикрепляю их к BannerView, все ломается: для некоторых по этой причине они начинают «сжиматься» до левой границы, а попытка увеличить ширину не дает никакого эффекта, увеличивается только рамка, ограничивающая вид.
SmallBannerView's макет:
Код: Выделить всё

< /p>
Макет LargeBannerView:
Код: Выделить всё

Макет BannerView:
Код: Выделить всё

Здесь также класс BannerView:
Код: Выделить всё
class BannerView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0,
) : RelativeLayout(context, attrs, defStyleAttr) {
private var binding: BannerViewBinding
init {
binding = BannerViewBinding.inflate(LayoutInflater.from(context))
addView(binding.root)
}
fun setupBanner(model: BannerUiModel) {
binding.large.setUpLarge(model.largeBanner)
binding.small.setUpSmall(model.smallBanner)
}
}
class LargeBannerView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0,
) : RelativeLayout(context, attrs, defStyleAttr) {
private var binding: LargeBannerViewBinding
init {
binding = LargeBannerViewBinding.inflate(LayoutInflater.from(context))
addView(binding.root)
}
fun setUpLarge(model: LargeBannerUiModel) {
binding.title.text = model.title
binding.description.text = model.description
binding.image.setImageDrawable(AppCompatResources.getDrawable(context, model.imageResId))
}
}
class SmallBannerView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0,
) : RelativeLayout(context, attrs, defStyleAttr) {
private var binding: SmallBannerViewBinding
init {
binding = SmallBannerViewBinding.inflate(LayoutInflater.from(context))
addView(binding.root)
}
fun setUpSmall(model: SmallBannerUiModel?) {
binding.rightTitle.text = model?.rightLabel
binding.leftTitle.text = model?.leftLabel
val imageId = model?.imageResId
if (imageId != null)
binding.image.setImageDrawable(AppCompatResources.getDrawable(context, imageId))
}
}

Я пытался удалить такие параметры, как maxLines и ellipsize, но это не дало результата.
Подробнее здесь: https://stackoverflow.com/questions/793 ... king-wider
Мобильная версия