滚动问题 - 当我向上移动滚动条时不向后滚动
Scrolling problem - doesn't scroll back when i move up the scroll bar
我正在 Xamarin android 中为通知 ui xml 实现 Recycler View 和 Card View。我感到困惑的是,当我 运行 我的代码时它可以清楚地工作,但是当我向上滚动时它在一个通知与另一个通知之间给出了很大的距离。这是主要 activity 的代码和输出的屏幕截图。
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"
});
这里还有一个githublink,大家要下载看看。和屏幕截图,可为您提供更好的信息。
将行 android:layout_height="match_parent" 设置为 wrap_content notification_items.xml.
我正在 Xamarin android 中为通知 ui xml 实现 Recycler View 和 Card View。我感到困惑的是,当我 运行 我的代码时它可以清楚地工作,但是当我向上滚动时它在一个通知与另一个通知之间给出了很大的距离。这是主要 activity 的代码和输出的屏幕截图。
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"
});
这里还有一个githublink,大家要下载看看。和屏幕截图,可为您提供更好的信息。
将行 android:layout_height="match_parent" 设置为 wrap_content notification_items.xml.