Comments (4)
Hi @fankloano. Can you please post the XML and kotlin code for your ViewHolders?
from dpadrecyclerview.
Following the xml-code of rv_item_movies:
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="160dp"
android:id="@+id/cardview_movie"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:cardCornerRadius="5dp"
app:cardElevation="2dp"
android:focusable="true"
android:focusableInTouchMode="true"
android:foreground="@drawable/selector_vod_card_background">
<FrameLayout
android:background="@color/colorBG"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="1dp">
<ImageView
android:id="@+id/ivMovies"
android:layout_width="match_parent"
android:layout_height="180dp"
android:scaleType="fitXY"
tools:src="@drawable/testposter"/>
<ImageView
android:id="@+id/tv_isFullyWatched"
android:layout_width="35dp"
android:layout_height="20dp"
android:background="#D02E3035"
android:src="@drawable/ic_checked"
android:layout_gravity="end"
app:tint="@color/light_blue"
android:visibility="invisible"/>
<TextView
android:id="@+id/tvMovies"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/ivMovies"
android:layout_gravity="bottom"
android:fontFamily="sans-serif-smallcaps"
android:gravity="center"
android:padding="5dp"
android:background="#C12E3035"
android:textColor="@color/white"
android:textSize="10dp"
android:typeface="monospace" />
<ImageView
android:id="@+id/tv_isFavorite"
android:layout_width="35dp"
android:layout_height="20dp"
android:background="#D02E3035"
android:src="@drawable/ic_favorite_vod"
android:layout_gravity="start"
android:visibility="invisible"/>
</FrameLayout>
</androidx.cardview.widget.CardView>
With kotlin code you mean the adapter code?
inner class ViewHolder(val binding: RvItemMoviesBinding) : RecyclerView.ViewHolder(binding.root) {
fun bind(movie: Movie) {
binding.apply {
tvMovies.text = movie.movieName
val image = movie.poster_url
if (!image.isNullOrEmpty()) {
Glide.with(itemView.context).load(image)
.into(ivMovies)
}
binding.tvIsFavorite.visibility = if (movie.isFavorite) View.VISIBLE else View.INVISIBLE
binding.cardviewMovie.setOnKeyListener { _, keyCode, event ->
if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT && event.action == KeyEvent.ACTION_DOWN) {
if (bindingAdapterPosition % 7 == 0) {
fragment.setMovieCategoriesVisibilityAnimated(true)
return@setOnKeyListener true
}
}
if (keyCode == KeyEvent.KEYCODE_BACK && event.action == KeyEvent.ACTION_DOWN) {
fragment.setMovieCategoriesVisibilityAnimated(true)
return@setOnKeyListener true
}
if (keyCode == KeyEvent.KEYCODE_DPAD_UP && event.action == KeyEvent.ACTION_DOWN) {
if (bindingAdapterPosition == 0) {
binding.cardviewMovie.requestFocus()
return@setOnKeyListener true
}
}
if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN && event.action == KeyEvent.ACTION_DOWN) {
if (bindingAdapterPosition == itemCount - 1) {
binding.cardviewMovie.requestFocus()
return@setOnKeyListener true
}
}
return@setOnKeyListener false
}
}
}
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val binding = RvItemMoviesBinding.inflate(
LayoutInflater.from(parent.context),
parent,
false
)
val viewHolder = ViewHolder(binding)
return viewHolder
}
@UnstableApi
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val movie = getItem(position)!!
holder.bind(movie)
holder.binding.cardviewMovie.setOnFocusChangeListener { _, hasFocus ->
if (hasFocus) {
fragment.setDetailsUi(movie)
} else {
}
}
}
from dpadrecyclerview.
So your problem seems to be the usage of DpadLinearSpacingDecoration
. Please use this instead: https://rubensousa.github.io/DpadRecyclerView/recipes/spacing/#grid-spacings
from dpadrecyclerview.
@rubensousa
sorry I overlooked the spacing recipes for grid..
using DpadGridSpacingDecoration solved the problem, thanks
from dpadrecyclerview.
Related Issues (20)
- Add navigation sound when searching for new view
- Add support for long text scrolling
- Scroll jumps to the top on item's layout update HOT 7
- Scroll position start question HOT 14
- Nested vertical lists HOT 1
- Vertical list with focus centered HOT 2
- IndexOutOfBoundsException but I can't reproduce it. HOT 5
- Touch behavior in scrolling HOT 5
- help HOT 2
- Focus issue after touch event
- How to implement StaggeredGridLayout? HOT 5
- Update compose integration now that view-interop is fixed
- Allow skipping layout requests during scroll
- Expose ViewHolder focus state
- Add support for custom parent alignment based on ViewHolder position
- Add support for linear circular focus
- Gridrecyclerview with height 0.5 of the screen height - alignment problem (last row cut off) HOT 14
- Fast scrolling - loosing focus when having images from an url in the items HOT 21
- Scrolling issue when loading images in onBindViewHolder HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dpadrecyclerview.