Bug Icon over foreground
Sulfkain opened this issue · 8 comments
That's strange can you tell me which android version are you on and if this happens with the sample app too?
I have tried with the sample and works fine
The version of the device tested is 8.0.0 and 8.1.0 and 9.0 so seems more it's something on my project than on yours
I use SVG and constraintLayout, could be something related with that, that you don't use it on your project?
This is my xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:tool="http://schemas.android.com/tools"
android:id="@+id/main_view"
android:padding="@dimen/margin">
<com.vanniktech.emoji.EmojiTextView
android:id="@+id/userEmoji"
android:layout_width="@dimen/emoji_text_size"
android:layout_height="@dimen/emoji_text_size"
app:emojiSize="@dimen/emoji_size"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/center_main"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/margin_bit"
android:layout_marginRight="@dimen/margin"
app:layout_constraintLeft_toRightOf="@id/userEmoji"
app:layout_constraintRight_toLeftOf="@id/delete"
app:layout_constraintTop_toTopOf="@id/userEmoji">
<TextView android:id="@+id/userName"
style="@style/cell_user_name"
android:textColor="@color/dark_gray"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:gravity="center_vertical"
app:layout_constrainedHeight="true"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_goneMarginLeft="0dp"
android:layout_marginLeft="@dimen/margin_tiny"
tool:text="User Name Lorem Ipsum A guachu pein maromin" />
<ImageView android:id="@+id/iconLocation"
android:layout_width="16dp"
android:layout_height="0dp"
android:scaleType="fitCenter"
android:src="@drawable/ic_location"
android:layout_marginTop="@dimen/margin_tiny"
app:layout_constraintDimensionRatio="h,1:1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/userName" />
<TextView android:id="@+id/location"
style="@style/frysbe_cell_detail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/margin_tiny"
android:maxLines="1"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toBottomOf="@id/iconLocation"
app:layout_constraintLeft_toRightOf="@id/iconLocation"
app:layout_constraintTop_toTopOf="@id/iconLocation"
tool:text="España" />
</androidx.constraintlayout.widget.ConstraintLayout>
<ImageView android:id="@+id/delete"
android:layout_width="0dp"
android:layout_height="0dp"
android:src="@drawable/ic_delete"
android:tint="@color/normalGrey"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintHeight_percent="0.5"
app:layout_constraintDimensionRatio="w,1:1" />
</androidx.constraintlayout.widget.ConstraintLayout>
And setup
fun BlockedUsersFragment.setupSwipeCells() {
ItemTouchHelper(object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT) {
override fun onMove(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean { return false }
override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {
val position = viewHolder.adapterPosition
showDeleteInfo(position, adapter.list[position])
}
override fun onChildDraw(
c: Canvas,
recyclerView: RecyclerView,
viewHolder: RecyclerView.ViewHolder,
dX: Float,
dY: Float,
actionState: Int,
isCurrentlyActive: Boolean
) {
createBackgroundSwipe(c, viewHolder, dX, dY, actionState, isCurrentlyActive)
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive)
}
}).attachToRecyclerView(usersBlocked)
}
private fun BlockedUsersFragment.createBackgroundSwipe(c: Canvas, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) {
context?.let {
RecyclerViewSwipeDecorator.Builder(it, c, usersBlocked, viewHolder, dX, dY, actionState, isCurrentlyActive)
.addSwipeLeftBackgroundColor(ContextCompat.getColor(it, R.color.delete_background))
.addSwipeLeftActionIcon(R.drawable.ic_delete)
.create()
.decorate()
}
}
I see you have fixed, could I try that version and confirm the fix? Could you explain how to get that dependency?
Any more info you need, just ask
Thank you
I've just published version 1.2 of the library with a possible fix of your issue, more than a fix it's an improvement of the previous code.
You can include it in your project as usual:
implementation 'it.xabaras.android:recyclerview-swipedecorator:1.2'
In version 1.2 you have also the ability to tint action icons.
Maybe give it a try and let me now.
BTW you shouldn't nest ConstraintLayouts
Ok Thanks!, I will give a try and I let you know what's happened if it fixed or not.
ConstraintLayout it's indeed for this, it's a powerfull layout with much more effective render time than Relative, Linear or Frame layout, is the solution to the slow render of the others layouts.
I have tried and still there the bug :(
Have you tried with ContraintsLayouts?
I have tried to change the svg with a .png and happens the same, so seems to pointing the ContraintLayout that I know it's render diferntly from RelativeLayout
Have you tried setting a background on the outer ConstraintLayout?
E.g. android:background="@android:color/white"