How to implement setOnScrollListener in RecyclerView

Activity Class with recylcerview in xml layout file public class WallpaperActivity extends AppCompatActivity implements OnTaskCompleted { private static final String TAG = “WallpaperActivity”; private Toolbar toolbar; private RecyclerView mRecyclerView; private WallPaperDataAdapter mAdapter; private LinearLayoutManager mLayoutManager; // to keep track which pages loaded and next pages to load public static int pageNumber; private List<WallPaper> wallpaperImagesList; protected … Read more

Unable to get exact circle shape when using card view

To achieve a circular shape using Card view you can set the shape property, android:shape=”ring”. app:cardCornerRadius should be set to half the width or height of the child view <android.support.v7.widget.CardView android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_centerInParent=”true” android:innerRadius=”0dp” android:shape=”ring” app:cardCornerRadius=”75dp”> <ImageView android:layout_width=”150dp” android:layout_height=”150dp” android:layout_gravity=”center” android:background=”@drawable/image” /> </android.support.v7.widget.CardView>

Changing CardView shadow color

Consider this thread in twitter, where Nick Butcher talks about how to implement the feature: See outlineAmbientShadowColor, outlineSpotShadowColor, spotShadowAlpha and ambientShadowAlpha attributes for details. Unfortunately, that’s possible from API 28 onwards. For lower APIs Nick has shared a gist. Here’s the result: Running on API 21 This technique isn’t directly connected to CardView, it can … Read more

Android CardView remove padding

UDPATE Well, seems there is a much easier way to do it, without guessing the padding and all: card_view:cardPreventCornerOverlap=”false” or using java: cardView.setPreventCornerOverlap(false) You can read all about it here. ORIGINAL ANSWER It is an intentional padding to avoid content from bleeding off the rounded corner of the card in pre lollipop versions (since clipping … Read more

android.graphics.drawable.ColorDrawable cannot be cast to android.support.v7.widget.RoundRectDrawableWithShadow

I get this error when calling setBackgroundColor() method, which is defined in View class. cardView.setBackgroundColor(Color.parseColor(“#ffffcc”)); Instead setCardBackgroundColor() method should be called, which is specific to CardViews and defined within CardView class. This code setting both background colour and the corner radius works for me: cardView.setCardBackgroundColor(Color.parseColor(“#ffffcc”)); cardView.setRadius(50);

RecyclerView 2 Columns with CardView

Extracted required info from the accepted answer in case URL becomes invalid in future and to save time. GridLayoutManager is used to display the RecyclerView in Grid manner instead of list. RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(this, 2); recyclerView.setLayoutManager(mLayoutManager); Kotlin version: recyclerView.apply { layoutManager = GridLayoutManager(this, 2) }

CardView background color states not being respected

Though this is not ideal, since the edges are not rounded, you can add touch feedback to a CardView like this : <android.support.v7.widget.CardView 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” app:cardCornerRadius=”4dp” android:clickable=”true” android:foreground=”?android:attr/selectableItemBackground”> //Nested View … </android.support.v7.widget.CardView> Adding the android:foreground and android:clickable attributes to the CardView. Also this has a negative side effect in that the android:clickable attribute … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)