Using the below function, I am trying to expand the height and width of an item in focus. The trouble I'm facing is the height is expanding towards the bottom only and the top seems to be fixed. I want the complete opposite.
inner class ItemViewSelectedListener : OnItemViewSelectedListener {
override fun onItemSelected(
itemViewHolder: Presenter.ViewHolder?,
item: Any?,
rowViewHolder: RowPresenter.ViewHolder?,
row: Row?
) {
if (item is MenuLabelI) {
val indexOfItem = ((row as ListRow).adapter as ArrayObjectAdapter).indexOf(item)
itemSelectedListener?.invoke(item)
itemIndexSelectedListener?.invoke(indexOfItem)
}
itemViewHolder?.view?.setOnFocusChangeListener { view, booleanValue ->
val layoutParams = view.layoutParams as ViewGroup.MarginLayoutParams
if (booleanValue) {
view.setBackgroundResource(R.color.selector_color_taj_trees)
layoutParams.width = getWidthInPercent(view.context, 14)
layoutParams.height = getHeightInPercent(view.context, 17)
view.layoutParams = layoutParams
} else {
view.setBackgroundResource(R.color.item_color_taj_trees)
layoutParams.width = getWidthInPercent(view.context, 12)
layoutParams.height = getHeightInPercent(view.context, 16)
view.layoutParams = layoutParams
}
}
}
}
I want the height to expand towards the top and the bottom should be fixed. I have tried using scaleX, scaleY but that only increases the size of the contents of the item, not the item itself. And layoutParams.setMargins is also not working. Whatever I do, the top seems to be fixed. Can anyone provide a solution to this?
There are some inbuilt zoom types for onFocus you can use it
while initialize
ListRowPresenterpass focusZoomFactor in parameterother zoom factor types