Reputation: 74
I am implementing Recycler View and Card View in Xamarin android for Notification ui xml. I got confused that when i run my code it works clearly but when i scroll up it gives a big distance between one notification to another. Here is a code of main activity and a screen shot of output.
using Android.OS;
using Android.Support.V7.App;
using Android.Runtime;
using Android.Widget;
using Android.Support.V7.Widget;
using App22.Helper;
using System;
using System.Collections.Generic;
namespace App22
{
[Activity(Label = "@string/app_name", Theme = "@style/Theme.AppCompat.Light.NoActionBar", MainLauncher = true)]
public class MainActivity : AppCompatActivity
{
private RecyclerView recycler;
private RecyclerViewAdapter adapter;
private RecyclerView.LayoutManager layoutManager;
private List<Data> lstData = new List<Data>();
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.activity_main);
InitData();
recycler = FindViewById<RecyclerView>(Resource.Id.recyclerView_Notifications);
recycler.HasFixedSize = true;
//layoutManager = new LinearLayoutManager(this);
layoutManager = new GridLayoutManager(this, 1, GridLayoutManager.Vertical, false);
recycler.SetLayoutManager(layoutManager);
adapter = new RecyclerViewAdapter(lstData);
recycler.SetAdapter(adapter);
}
private void InitData()
{
lstData.Add(new Data()
{
userProfile = "you can write here base 64 string of image",
issueInfo="abc",
tvtime_noti="24m",
userName="Nabeel"
}) ;
lstData.Add(new Data()
{
userProfile = "you can write here base 64 string of image",
issueInfo = "abc",
tvtime_noti = "24m",
userName = "Nabeel"
});
lstData.Add(new Data()
{
userProfile = "you can write here base 64 string of image",
issueInfo = "abc",
tvtime_noti = "24m",
userName = "Nabeel"
});
lstData.Add(new Data()
{
userProfile = "you can write here base 64 string of image"
issueInfo = "abc",
tvtime_noti = "24m",
userName = "Nabeel"
});
Here is also a github link if you want to download and check it. and screen shot which gives you better information.
Upvotes: 1
Views: 95
Reputation: 18861
Set the line android:layout_height="match_parent" to wrap_content in notification_items.xml .
Upvotes: 2