Open dzordz55 opened 9 years ago
I have a problem with displaying images in CardListView. Cards looks like below:
This is my layout with CardListView. If it's important, layout is in SlidingUpPanelLayout view from https://github.com/umano/AndroidSlidingUpPanel
<it.gmariotti.cardslib.library.view.CardListView android:id="@+id/cardlistview" android:layout_width="match_parent" android:layout_height="match_parent" style="@style/list_card.thumbnail" card:list_card_layout_resourceID="@layout/list_card_thumbnail_layout" />
My custom card layout:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:padding="10dp" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/card_thumbnail_image"/> <TextView android:id="@+id/card_main_inner_simple_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Large Text" android:textAppearance="?android:attr/textAppearanceLarge" /> <TextView android:id="@+id/card_main_inner_secondary_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Cardslib" android:textAppearance="?android:attr/textAppearanceMedium" />
And code where I add images:
ArrayList<Card> cards = new ArrayList<>(); for(int i = 0; i < data.size(); i++) { Card card = new Card(getActivity(), R.layout.card_layout); card.setBackgroundColorResourceId(R.color.colorCard); CardThumbnail thumb = new CardThumbnail(getActivity()); thumb.setDrawableResource(R.drawable.ic_delete); card.addCardThumbnail(thumb); cards.add(card); } CardArrayAdapter cardArrayAdapter = new CardArrayAdapter(getActivity(), cards); CardListView listView = (CardListView) getView().findViewById(R.id.cardlistview); if (listView != null) listView.setAdapter(cardArrayAdapter); cardArrayAdapter.notifyDataSetChanged();
I got the same problem once. I overcame this by using CardRecyclerView instead of CardListView.
I have a problem with displaying images in CardListView. Cards looks like below:
This is my layout with CardListView. If it's important, layout is in SlidingUpPanelLayout view from https://github.com/umano/AndroidSlidingUpPanel
My custom card layout:
And code where I add images: