C# RecyclerView仅显示设备上的前两行
在我的模拟器中,它像预期的那样将我的视图放大10行,但当我在我的设备(Galaxy S4 v6.0)上运行它时,它只显示2行。我在手机上使用的是安卓v7.0,但降级到v6.0,看看这是否是问题所在,但这并没有解决问题。在调试或发布时运行它不会改变任何事情C# RecyclerView仅显示设备上的前两行,c#,android,xamarin,xamarin.android,C#,Android,Xamarin,Xamarin.android,在我的模拟器中,它像预期的那样将我的视图放大10行,但当我在我的设备(Galaxy S4 v6.0)上运行它时,它只显示2行。我在手机上使用的是安卓v7.0,但降级到v6.0,看看这是否是问题所在,但这并没有解决问题。在调试或发布时运行它不会改变任何事情 button2nd.Click += async (_, __) => { await mclass.GetSummonerInformation();
button2nd.Click += async (_, __) =>
{
await mclass.GetSummonerInformation();
iconUrl = string.Format("http://ddragon.leagueoflegends.com/cdn/6.24.1/img/profileicon/" + MyClass.sumProfileIconId + ".png");
DisplaySummonerIcon(iconUrl, imageView1);
await mclass.GetSummonerMatchList();
function1();
};
private void function1()
{
game.Clear();
mAdapter.NotifyDataSetChanged();
Thread.Sleep(1000);
System.Diagnostics.Debug.WriteLine("This is from the recentgamesdoworkcompleted");
for (int i = 0; i < 10; i++)
{
if (mclass.win[i])
{
winorlose = Color.ParseColor("#42A5F5");
}
else
{
winorlose = Color.ParseColor("#D32F2F");
}
System.Diagnostics.Debug.WriteLine("This is from inside the loop of recentgamesdoworkcompleted");
game.Add(new Models.MatchHistoryListView()
{
Name = "" + mclass.summonerId[0, i],
ChampionId = mclass.championId[0, i],
Id = i,
Score = mclass.summonerScoreText[i],
championPortraito = new Uri("http://ddragon.leagueoflegends.com/cdn/6.24.1/img/champion/" + mclass.championName[0, i] + ".png"),
Item0 = new Uri("http://ddragon.leagueoflegends.com/cdn/6.24.1/img/item/" + mclass.summonerItems[i, 0] + ".png"),
Item1 = new Uri("http://ddragon.leagueoflegends.com/cdn/6.24.1/img/item/" + mclass.summonerItems[i, 1] + ".png"),
Item2 = new Uri("http://ddragon.leagueoflegends.com/cdn/6.24.1/img/item/" + mclass.summonerItems[i, 2] + ".png"),
Item3 = new Uri("http://ddragon.leagueoflegends.com/cdn/6.24.1/img/item/" + mclass.summonerItems[i, 3] + ".png"),
Item4 = new Uri("http://ddragon.leagueoflegends.com/cdn/6.24.1/img/item/" + mclass.summonerItems[i, 4] + ".png"),
Item5 = new Uri("http://ddragon.leagueoflegends.com/cdn/6.24.1/img/item/" + mclass.summonerItems[i, 5] + ".png"),
Item6 = new Uri("http://ddragon.leagueoflegends.com/cdn/6.24.1/img/item/" + mclass.summonerItems[i, 6] + ".png"),
listViewColor = winorlose
});
}
}
button2nd.Click+=async(u,u)=>
{
等待mclass.getcallerinformation();
iconUrl=string.Format(“http://ddragon.leagueoflegends.com/cdn/6.24.1/img/profileicon/“+MyClass.sumProfileIconId+”.png”);
显示召唤图标(iconUrl,imageView1);
等待mclass.getCalleraterMatchList();
功能1();
};
私有函数1()
{
游戏。清除();
mAdapter.NotifyDataSetChanged();
睡眠(1000);
System.Diagnostics.Debug.WriteLine(“这来自最近的GamesDowWorkCompleted”);
对于(int i=0;i<10;i++)
{
如果(mclass.win[i])
{
winorlose=Color.ParseColor(#42A5F5”);
}
其他的
{
winorlose=Color.ParseColor(#D32F2F”);
}
System.Diagnostics.Debug.WriteLine(“这是从最近的GamesDowWorkCompleted循环中获取的”);
game.Add(新模型.MatchHistoryListView()
{
Name=“”+mclass.召唤ID[0,i],
ChampionId=mclass.ChampionId[0,i],
Id=i,
分数=mclass.callerscoretext[i],
championo=新Uri(“http://ddragon.leagueoflegends.com/cdn/6.24.1/img/champion/“+mclass.championName[0,i]+.png”),
Item0=新Uri(“http://ddragon.leagueoflegends.com/cdn/6.24.1/img/item/“+mclass.callereItems[i,0]+.png”),
Item1=新Uri(“http://ddragon.leagueoflegends.com/cdn/6.24.1/img/item/“+mclass.callereItems[i,1]+.png”),
Item2=新Uri(“http://ddragon.leagueoflegends.com/cdn/6.24.1/img/item/“+mclass.callereItems[i,2]+.png”),
Item3=新Uri(“http://ddragon.leagueoflegends.com/cdn/6.24.1/img/item/“+mclass.callereItems[i,3]+.png”),
Item4=新Uri(“http://ddragon.leagueoflegends.com/cdn/6.24.1/img/item/“+mclass.callereItems[i,4]+.png”),
Item5=新Uri(“http://ddragon.leagueoflegends.com/cdn/6.24.1/img/item/“+mclass.callereItems[i,5]+.png”),
Item6=新Uri(“http://ddragon.leagueoflegends.com/cdn/6.24.1/img/item/“+mclass.callereItems[i,6]+.png”),
listViewColor=winorlose
});
}
}
这里是Main.axml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:nestedScrollingEnabled="false">
<LinearLayout
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:text="Get Summoner Information"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/button1" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="378.5dp"
android:layout_height="49.0dp"
android:id="@+id/linearLayout1">
<Spinner
android:id="@+id/spinner1"
android:layout_width="81.0dp"
android:layout_height="41.0dp" />
<EditText
android:inputType="textPersonName"
android:id="@+id/editText1"
android:hint="Type your username here!"
android:layout_width="295.5dp"
android:layout_height="match_parent" />
</LinearLayout>
<ImageView
android:layout_width="250.5dp"
android:layout_height="113.5dp"
android:id="@+id/summonerIcon1"
android:visibility="visible"
android:layout_gravity="center" />
<TextView
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView1"
android:text="Summoner Information"
android:gravity="center" />
<TextView
android:text="Name:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/nameText" />
<TextView
android:text="User Id:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/userIdText" />
<TextView
android:text="Revision Date:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/revisionDateText" />
<Button
android:text="Get Mach History"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/matchList" />
<Button
android:text="Show Last Game info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/lastGameInfoBtn" />
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/recyclerView"
android:nestedScrollingEnabled="false"/>
</LinearLayout>
</ScrollView>
通过使用Android.Support.v4中的NestedScrollView修复了此问题,因为API 23和API 24中存在一个已知错误,导致了我遇到的问题。我猜您的视图只有足够的空间容纳两个项目来填充父项。因此,您必须发布更多代码,如布局XML。似乎是nestedScrollingEnabled出现了问题。禁用该选项可使我滚动浏览位于布局底部的回收器视图,但我需要它拉伸并显示其所有项目。删除该选项并不能提供所需的外观。更新了我的操作。