Skip to content

Fix swipe sample item colors #941

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.mikepenz.fastadapter.app.items

import android.graphics.Color
import android.view.View
import android.widget.TextView
import androidx.annotation.StringRes
Expand Down Expand Up @@ -135,11 +134,12 @@ class SwipeableDrawerItem : AbstractItem<SwipeableDrawerItem.ViewHolder>(), ISwi
}

override fun onDropped() {
itemContent.setBackgroundColor(Color.WHITE)
// note this is only to showcase this callback, remember that changes to the item need to be remembered when a viewHolder is re-used
// itemContent.setBackgroundColor(itemContent.context.getThemeColor(R.attr.colorPrimary))
}

override fun onDragged() {
itemContent.setBackgroundColor(Color.LTGRAY)
// itemContent.setBackgroundColor(itemContent.context.getThemeColor(R.attr.colorPrimary))
}

override val swipeableView: View
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/swipeable_drawer_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,11 @@
android:id="@+id/item_content"
android:layout_width="match_parent"
android:layout_height="@dimen/material_drawer_item_primary"
android:background="@android:color/white"
android:background="?android:colorBackground"
android:clickable="true"
android:elevation="4dp"
android:focusable="true"
android:foreground="?android:selectableItemBackground"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Attribute android:foreground has no effect on API levels lower than 23 (current min is 16)

android:gravity="center_vertical|start"
android:orientation="vertical"
android:paddingStart="@dimen/material_drawer_vertical_padding"
Expand Down