我正在实现回收视图和卡视图在Xamarin android的通知用户界面xml。我感到困惑的是,当我运行我的代码时,它工作得很清楚,但是当我向上滚动时,它会在一个通知与另一个通知之间产生很大的距离。这是主要活动的代码和输出的屏幕截图。
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"
});如果您想下载并检查它,这里还有一个github链接。屏幕截图给你更好的信息。

发布于 2020-12-28 11:42:39
将notification_items.xml中的android:layout_height="match_parent“行设置为wrap_content。

https://stackoverflow.com/questions/65475965
复制相似问题