Items using CardLayout and RecyclerView not displaying correctly












2














I am currently following this tutorial : https://code.tutsplus.com/tutorials/getting-started-with-recyclerview-and-cardview-on-android--cms-23465



I am trying to list a number of Cards to the Recycler View however when for some reason after following the tutorial and supplied code it looks like there is only one card and all the contents are in one card. See image :



enter image description here



All the objects defined in the initData method show up but as I mentioned it seems like all these objects are added to just one card? Any help would be greatly appreciated!



quiz_item_ui.xml



    <?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/cv">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/person_photo"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/person_name"
android:layout_toRightOf="@+id/person_photo"
android:layout_toEndOf="@id/person_photo"
android:layout_alignParentTop="true"
android:textSize="30sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/person_age"
android:layout_toRightOf="@+id/person_photo"
android:layout_toEndOf="@id/person_photo"
android:layout_below="@+id/person_name"/>

</RelativeLayout>

</android.support.v7.widget.CardView>


activity_home.xml



 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
tools:context=".HomeActivity">

<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/rv">

</android.support.v7.widget.RecyclerView>


</LinearLayout>


QuizItemAdapter.java



    public class QuizItemAdapter extends RecyclerView.Adapter<QuizItemAdapter.QuizItemViewHolder>
{

public static class QuizItemViewHolder extends RecyclerView.ViewHolder {
CardView cv;
TextView personName;
TextView personAge;
ImageView personPhoto;

QuizItemViewHolder(View itemView)
{
super(itemView);
cv = itemView.findViewById(R.id.cv);
personName = itemView.findViewById(R.id.person_name);
personAge = itemView.findViewById(R.id.person_age);
personPhoto = itemView.findViewById(R.id.person_photo);

}
}
List<QuizItem> items;

QuizItemAdapter(List<QuizItem> items)
{
this.items = items;
}

@Override
public QuizItemViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i)
{
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.quiz_item_ui,viewGroup,false);
QuizItemViewHolder qi = new QuizItemViewHolder(v);
return qi;
}

@Override
public void onBindViewHolder(QuizItemViewHolder quizItemViewHolder, int i)
{
quizItemViewHolder.personName.setText(items.get(i).name);
quizItemViewHolder.personAge.setText(items.get(i).age);
quizItemViewHolder.personPhoto.setImageResource(items.get(i).photoId);
}

@Override
public int getItemCount()
{
return items.size();
}
}


HomeActivity.java



    public class HomeActivity extends AppCompatActivity
{
private List<QuizItem> qItems;
private RecyclerView rv;

@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);

rv = findViewById(R.id.rv);
LinearLayoutManager lm = new LinearLayoutManager(this);
rv.setLayoutManager(lm);
rv.setHasFixedSize(true);

initData();
initAdapter();
}
private void initData()
{
qItems = new ArrayList<>();
qItems.add(new QuizItem("Emma Wilson","23 years old",R.drawable.ic_location));
qItems.add(new QuizItem("Emma Wilson","23 years old",R.drawable.ic_location));
qItems.add(new QuizItem("Emma Wilson","23 years old",R.drawable.ic_location));

}

private void initAdapter()
{
QuizItemAdapter a = new QuizItemAdapter(qItems);
rv.setAdapter(a);
}


}


Thanks !










share|improve this question




















  • 1




    Why you use CardView Height match_parent ? use Height as Wrap_content
    – Ashish
    Nov 22 at 18:33








  • 1




    Oops, that was supposed to be "wrap_content"! That was one of the issues, although the contents do not spit out into their individual card views
    – GrandeurH
    Nov 22 at 18:38












  • Can you show me Image now
    – Ashish
    Nov 22 at 18:39












  • Thanks for spotting that! I updated the screenshot to show what it looks like now :D
    – GrandeurH
    Nov 22 at 18:39










  • I use Picasso for show picture in CardView I m Kotlin Android Developer Don't know much About Java So try using Picasso for Images
    – Ashish
    Nov 22 at 18:46
















2














I am currently following this tutorial : https://code.tutsplus.com/tutorials/getting-started-with-recyclerview-and-cardview-on-android--cms-23465



I am trying to list a number of Cards to the Recycler View however when for some reason after following the tutorial and supplied code it looks like there is only one card and all the contents are in one card. See image :



enter image description here



All the objects defined in the initData method show up but as I mentioned it seems like all these objects are added to just one card? Any help would be greatly appreciated!



quiz_item_ui.xml



    <?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/cv">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/person_photo"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/person_name"
android:layout_toRightOf="@+id/person_photo"
android:layout_toEndOf="@id/person_photo"
android:layout_alignParentTop="true"
android:textSize="30sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/person_age"
android:layout_toRightOf="@+id/person_photo"
android:layout_toEndOf="@id/person_photo"
android:layout_below="@+id/person_name"/>

</RelativeLayout>

</android.support.v7.widget.CardView>


activity_home.xml



 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
tools:context=".HomeActivity">

<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/rv">

</android.support.v7.widget.RecyclerView>


</LinearLayout>


QuizItemAdapter.java



    public class QuizItemAdapter extends RecyclerView.Adapter<QuizItemAdapter.QuizItemViewHolder>
{

public static class QuizItemViewHolder extends RecyclerView.ViewHolder {
CardView cv;
TextView personName;
TextView personAge;
ImageView personPhoto;

QuizItemViewHolder(View itemView)
{
super(itemView);
cv = itemView.findViewById(R.id.cv);
personName = itemView.findViewById(R.id.person_name);
personAge = itemView.findViewById(R.id.person_age);
personPhoto = itemView.findViewById(R.id.person_photo);

}
}
List<QuizItem> items;

QuizItemAdapter(List<QuizItem> items)
{
this.items = items;
}

@Override
public QuizItemViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i)
{
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.quiz_item_ui,viewGroup,false);
QuizItemViewHolder qi = new QuizItemViewHolder(v);
return qi;
}

@Override
public void onBindViewHolder(QuizItemViewHolder quizItemViewHolder, int i)
{
quizItemViewHolder.personName.setText(items.get(i).name);
quizItemViewHolder.personAge.setText(items.get(i).age);
quizItemViewHolder.personPhoto.setImageResource(items.get(i).photoId);
}

@Override
public int getItemCount()
{
return items.size();
}
}


HomeActivity.java



    public class HomeActivity extends AppCompatActivity
{
private List<QuizItem> qItems;
private RecyclerView rv;

@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);

rv = findViewById(R.id.rv);
LinearLayoutManager lm = new LinearLayoutManager(this);
rv.setLayoutManager(lm);
rv.setHasFixedSize(true);

initData();
initAdapter();
}
private void initData()
{
qItems = new ArrayList<>();
qItems.add(new QuizItem("Emma Wilson","23 years old",R.drawable.ic_location));
qItems.add(new QuizItem("Emma Wilson","23 years old",R.drawable.ic_location));
qItems.add(new QuizItem("Emma Wilson","23 years old",R.drawable.ic_location));

}

private void initAdapter()
{
QuizItemAdapter a = new QuizItemAdapter(qItems);
rv.setAdapter(a);
}


}


Thanks !










share|improve this question




















  • 1




    Why you use CardView Height match_parent ? use Height as Wrap_content
    – Ashish
    Nov 22 at 18:33








  • 1




    Oops, that was supposed to be "wrap_content"! That was one of the issues, although the contents do not spit out into their individual card views
    – GrandeurH
    Nov 22 at 18:38












  • Can you show me Image now
    – Ashish
    Nov 22 at 18:39












  • Thanks for spotting that! I updated the screenshot to show what it looks like now :D
    – GrandeurH
    Nov 22 at 18:39










  • I use Picasso for show picture in CardView I m Kotlin Android Developer Don't know much About Java So try using Picasso for Images
    – Ashish
    Nov 22 at 18:46














2












2








2







I am currently following this tutorial : https://code.tutsplus.com/tutorials/getting-started-with-recyclerview-and-cardview-on-android--cms-23465



I am trying to list a number of Cards to the Recycler View however when for some reason after following the tutorial and supplied code it looks like there is only one card and all the contents are in one card. See image :



enter image description here



All the objects defined in the initData method show up but as I mentioned it seems like all these objects are added to just one card? Any help would be greatly appreciated!



quiz_item_ui.xml



    <?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/cv">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/person_photo"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/person_name"
android:layout_toRightOf="@+id/person_photo"
android:layout_toEndOf="@id/person_photo"
android:layout_alignParentTop="true"
android:textSize="30sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/person_age"
android:layout_toRightOf="@+id/person_photo"
android:layout_toEndOf="@id/person_photo"
android:layout_below="@+id/person_name"/>

</RelativeLayout>

</android.support.v7.widget.CardView>


activity_home.xml



 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
tools:context=".HomeActivity">

<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/rv">

</android.support.v7.widget.RecyclerView>


</LinearLayout>


QuizItemAdapter.java



    public class QuizItemAdapter extends RecyclerView.Adapter<QuizItemAdapter.QuizItemViewHolder>
{

public static class QuizItemViewHolder extends RecyclerView.ViewHolder {
CardView cv;
TextView personName;
TextView personAge;
ImageView personPhoto;

QuizItemViewHolder(View itemView)
{
super(itemView);
cv = itemView.findViewById(R.id.cv);
personName = itemView.findViewById(R.id.person_name);
personAge = itemView.findViewById(R.id.person_age);
personPhoto = itemView.findViewById(R.id.person_photo);

}
}
List<QuizItem> items;

QuizItemAdapter(List<QuizItem> items)
{
this.items = items;
}

@Override
public QuizItemViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i)
{
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.quiz_item_ui,viewGroup,false);
QuizItemViewHolder qi = new QuizItemViewHolder(v);
return qi;
}

@Override
public void onBindViewHolder(QuizItemViewHolder quizItemViewHolder, int i)
{
quizItemViewHolder.personName.setText(items.get(i).name);
quizItemViewHolder.personAge.setText(items.get(i).age);
quizItemViewHolder.personPhoto.setImageResource(items.get(i).photoId);
}

@Override
public int getItemCount()
{
return items.size();
}
}


HomeActivity.java



    public class HomeActivity extends AppCompatActivity
{
private List<QuizItem> qItems;
private RecyclerView rv;

@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);

rv = findViewById(R.id.rv);
LinearLayoutManager lm = new LinearLayoutManager(this);
rv.setLayoutManager(lm);
rv.setHasFixedSize(true);

initData();
initAdapter();
}
private void initData()
{
qItems = new ArrayList<>();
qItems.add(new QuizItem("Emma Wilson","23 years old",R.drawable.ic_location));
qItems.add(new QuizItem("Emma Wilson","23 years old",R.drawable.ic_location));
qItems.add(new QuizItem("Emma Wilson","23 years old",R.drawable.ic_location));

}

private void initAdapter()
{
QuizItemAdapter a = new QuizItemAdapter(qItems);
rv.setAdapter(a);
}


}


Thanks !










share|improve this question















I am currently following this tutorial : https://code.tutsplus.com/tutorials/getting-started-with-recyclerview-and-cardview-on-android--cms-23465



I am trying to list a number of Cards to the Recycler View however when for some reason after following the tutorial and supplied code it looks like there is only one card and all the contents are in one card. See image :



enter image description here



All the objects defined in the initData method show up but as I mentioned it seems like all these objects are added to just one card? Any help would be greatly appreciated!



quiz_item_ui.xml



    <?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/cv">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/person_photo"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/person_name"
android:layout_toRightOf="@+id/person_photo"
android:layout_toEndOf="@id/person_photo"
android:layout_alignParentTop="true"
android:textSize="30sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/person_age"
android:layout_toRightOf="@+id/person_photo"
android:layout_toEndOf="@id/person_photo"
android:layout_below="@+id/person_name"/>

</RelativeLayout>

</android.support.v7.widget.CardView>


activity_home.xml



 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
tools:context=".HomeActivity">

<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/rv">

</android.support.v7.widget.RecyclerView>


</LinearLayout>


QuizItemAdapter.java



    public class QuizItemAdapter extends RecyclerView.Adapter<QuizItemAdapter.QuizItemViewHolder>
{

public static class QuizItemViewHolder extends RecyclerView.ViewHolder {
CardView cv;
TextView personName;
TextView personAge;
ImageView personPhoto;

QuizItemViewHolder(View itemView)
{
super(itemView);
cv = itemView.findViewById(R.id.cv);
personName = itemView.findViewById(R.id.person_name);
personAge = itemView.findViewById(R.id.person_age);
personPhoto = itemView.findViewById(R.id.person_photo);

}
}
List<QuizItem> items;

QuizItemAdapter(List<QuizItem> items)
{
this.items = items;
}

@Override
public QuizItemViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i)
{
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.quiz_item_ui,viewGroup,false);
QuizItemViewHolder qi = new QuizItemViewHolder(v);
return qi;
}

@Override
public void onBindViewHolder(QuizItemViewHolder quizItemViewHolder, int i)
{
quizItemViewHolder.personName.setText(items.get(i).name);
quizItemViewHolder.personAge.setText(items.get(i).age);
quizItemViewHolder.personPhoto.setImageResource(items.get(i).photoId);
}

@Override
public int getItemCount()
{
return items.size();
}
}


HomeActivity.java



    public class HomeActivity extends AppCompatActivity
{
private List<QuizItem> qItems;
private RecyclerView rv;

@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);

rv = findViewById(R.id.rv);
LinearLayoutManager lm = new LinearLayoutManager(this);
rv.setLayoutManager(lm);
rv.setHasFixedSize(true);

initData();
initAdapter();
}
private void initData()
{
qItems = new ArrayList<>();
qItems.add(new QuizItem("Emma Wilson","23 years old",R.drawable.ic_location));
qItems.add(new QuizItem("Emma Wilson","23 years old",R.drawable.ic_location));
qItems.add(new QuizItem("Emma Wilson","23 years old",R.drawable.ic_location));

}

private void initAdapter()
{
QuizItemAdapter a = new QuizItemAdapter(qItems);
rv.setAdapter(a);
}


}


Thanks !







android






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 at 18:42

























asked Nov 22 at 18:30









GrandeurH

709




709








  • 1




    Why you use CardView Height match_parent ? use Height as Wrap_content
    – Ashish
    Nov 22 at 18:33








  • 1




    Oops, that was supposed to be "wrap_content"! That was one of the issues, although the contents do not spit out into their individual card views
    – GrandeurH
    Nov 22 at 18:38












  • Can you show me Image now
    – Ashish
    Nov 22 at 18:39












  • Thanks for spotting that! I updated the screenshot to show what it looks like now :D
    – GrandeurH
    Nov 22 at 18:39










  • I use Picasso for show picture in CardView I m Kotlin Android Developer Don't know much About Java So try using Picasso for Images
    – Ashish
    Nov 22 at 18:46














  • 1




    Why you use CardView Height match_parent ? use Height as Wrap_content
    – Ashish
    Nov 22 at 18:33








  • 1




    Oops, that was supposed to be "wrap_content"! That was one of the issues, although the contents do not spit out into their individual card views
    – GrandeurH
    Nov 22 at 18:38












  • Can you show me Image now
    – Ashish
    Nov 22 at 18:39












  • Thanks for spotting that! I updated the screenshot to show what it looks like now :D
    – GrandeurH
    Nov 22 at 18:39










  • I use Picasso for show picture in CardView I m Kotlin Android Developer Don't know much About Java So try using Picasso for Images
    – Ashish
    Nov 22 at 18:46








1




1




Why you use CardView Height match_parent ? use Height as Wrap_content
– Ashish
Nov 22 at 18:33






Why you use CardView Height match_parent ? use Height as Wrap_content
– Ashish
Nov 22 at 18:33






1




1




Oops, that was supposed to be "wrap_content"! That was one of the issues, although the contents do not spit out into their individual card views
– GrandeurH
Nov 22 at 18:38






Oops, that was supposed to be "wrap_content"! That was one of the issues, although the contents do not spit out into their individual card views
– GrandeurH
Nov 22 at 18:38














Can you show me Image now
– Ashish
Nov 22 at 18:39






Can you show me Image now
– Ashish
Nov 22 at 18:39














Thanks for spotting that! I updated the screenshot to show what it looks like now :D
– GrandeurH
Nov 22 at 18:39




Thanks for spotting that! I updated the screenshot to show what it looks like now :D
– GrandeurH
Nov 22 at 18:39












I use Picasso for show picture in CardView I m Kotlin Android Developer Don't know much About Java So try using Picasso for Images
– Ashish
Nov 22 at 18:46




I use Picasso for show picture in CardView I m Kotlin Android Developer Don't know much About Java So try using Picasso for Images
– Ashish
Nov 22 at 18:46












1 Answer
1






active

oldest

votes


















1














The cards are there - you can spot tiny triangle shadows between them on the sides. The shadow needs some space to draw itself. You need to remove padding from the main layout and add some margin to card's layout.



<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp" // remove this padding
tools:context=".HomeActivity">


And



<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp" // add margin here
android:id="@+id/cv"/>





share|improve this answer





















  • Outstanding, not sure how I missed this, exactly what I was looking for!
    – GrandeurH
    Nov 22 at 18:51










  • if you solved your issue give People Upvote.
    – Ashish
    Nov 23 at 9:07











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53436489%2fitems-using-cardlayout-and-recyclerview-not-displaying-correctly%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














The cards are there - you can spot tiny triangle shadows between them on the sides. The shadow needs some space to draw itself. You need to remove padding from the main layout and add some margin to card's layout.



<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp" // remove this padding
tools:context=".HomeActivity">


And



<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp" // add margin here
android:id="@+id/cv"/>





share|improve this answer





















  • Outstanding, not sure how I missed this, exactly what I was looking for!
    – GrandeurH
    Nov 22 at 18:51










  • if you solved your issue give People Upvote.
    – Ashish
    Nov 23 at 9:07
















1














The cards are there - you can spot tiny triangle shadows between them on the sides. The shadow needs some space to draw itself. You need to remove padding from the main layout and add some margin to card's layout.



<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp" // remove this padding
tools:context=".HomeActivity">


And



<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp" // add margin here
android:id="@+id/cv"/>





share|improve this answer





















  • Outstanding, not sure how I missed this, exactly what I was looking for!
    – GrandeurH
    Nov 22 at 18:51










  • if you solved your issue give People Upvote.
    – Ashish
    Nov 23 at 9:07














1












1








1






The cards are there - you can spot tiny triangle shadows between them on the sides. The shadow needs some space to draw itself. You need to remove padding from the main layout and add some margin to card's layout.



<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp" // remove this padding
tools:context=".HomeActivity">


And



<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp" // add margin here
android:id="@+id/cv"/>





share|improve this answer












The cards are there - you can spot tiny triangle shadows between them on the sides. The shadow needs some space to draw itself. You need to remove padding from the main layout and add some margin to card's layout.



<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp" // remove this padding
tools:context=".HomeActivity">


And



<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp" // add margin here
android:id="@+id/cv"/>






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 22 at 18:48









Zielony

10.6k42734




10.6k42734












  • Outstanding, not sure how I missed this, exactly what I was looking for!
    – GrandeurH
    Nov 22 at 18:51










  • if you solved your issue give People Upvote.
    – Ashish
    Nov 23 at 9:07


















  • Outstanding, not sure how I missed this, exactly what I was looking for!
    – GrandeurH
    Nov 22 at 18:51










  • if you solved your issue give People Upvote.
    – Ashish
    Nov 23 at 9:07
















Outstanding, not sure how I missed this, exactly what I was looking for!
– GrandeurH
Nov 22 at 18:51




Outstanding, not sure how I missed this, exactly what I was looking for!
– GrandeurH
Nov 22 at 18:51












if you solved your issue give People Upvote.
– Ashish
Nov 23 at 9:07




if you solved your issue give People Upvote.
– Ashish
Nov 23 at 9:07


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53436489%2fitems-using-cardlayout-and-recyclerview-not-displaying-correctly%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Trompette piccolo

Slow SSRS Report in dynamic grouping and multiple parameters

Simon Yates (cyclisme)