Android 多个MvxBindableListView';它在一个布局中?
我一直试图在布局中放置3个MvxBindableListView小部件,但没有成功。 有没有办法做到这一点,使每个MvxBindableListView完全显示,而无需内部滚动,并使我的“页面”可滚动。 这是布局图:Android 多个MvxBindableListView';它在一个布局中?,android,xamarin.android,mvvmcross,Android,Xamarin.android,Mvvmcross,我一直试图在布局中放置3个MvxBindableListView小部件,但没有成功。 有没有办法做到这一点,使每个MvxBindableListView完全显示,而无需内部滚动,并使我的“页面”可滚动。 这是布局图: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:local="http://schemas.android.com/apk/res/MyCurrentProj
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res/MyCurrentProject.Client.UI"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
local:MvxBind="{}" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:textAppearance="?android:attr/textAppearanceLarge"
local:MvxBind="{}" />
<Mvx.MvxBindableListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="false"
local:MvxBind="{}" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:textAppearance="?android:attr/textAppearanceLarge"
local:MvxBind="{}" />
<Mvx.MvxBindableListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="false"
local:MvxBind="{}" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:textAppearance="?android:attr/textAppearanceLarge"
local:MvxBind="{}" />
<Mvx.MvxBindableListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="false"
local:MvxBind="{}" />
</LinearLayout>
</LinearLayout>
此处绑定为空,但完全工作。列表中的元素数量可变,因此无法固定高度
提前谢谢 < P>检查<代码> MVXBDabeleLeNeLays< /C> >但很明显,您可以使用很多额外的资源(内存、图形对象等)如果你在一个或多个长列表中显示一个或多个长列表, 检查<代码> MVXBDabeleLeNeLays< /C> >但是很明显,你可以使用很多额外的资源(内存、图形对象等)。如果您完整地显示一个或多个长列表。您可以使用一种技巧使列表增长,然后将其放置在滚动视图中。请参阅下面的代码。您将以与常规MvxBindableListView相同的方式使用它
public class BindableExpandableHeightListView : MvxBindableListView
{
public BindableExpandableHeightListView(Context context, IAttributeSet attrs) : base(context, attrs) { }
public BindableExpandableHeightListView(Context context, IAttributeSet attrs, MvxBindableListAdapter adapter) : base(context, attrs, adapter) { }
private bool _isExpanded = true;
protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
if (_isExpanded)
{
int expandSpec = MeasureSpec.MakeMeasureSpec(int.MaxValue >> 2, MeasureSpecMode.AtMost);
base.OnMeasure(widthMeasureSpec, expandSpec);
ViewGroup.LayoutParams layoutParams = LayoutParameters;
layoutParams.Height = MeasuredHeight;
}
else
{
base.OnMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
}
您可以使用一个技巧使列表增长,然后将它们放在滚动视图中。请参阅下面的代码。您将以与常规MvxBindableListView相同的方式使用它
public class BindableExpandableHeightListView : MvxBindableListView
{
public BindableExpandableHeightListView(Context context, IAttributeSet attrs) : base(context, attrs) { }
public BindableExpandableHeightListView(Context context, IAttributeSet attrs, MvxBindableListAdapter adapter) : base(context, attrs, adapter) { }
private bool _isExpanded = true;
protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
if (_isExpanded)
{
int expandSpec = MeasureSpec.MakeMeasureSpec(int.MaxValue >> 2, MeasureSpecMode.AtMost);
base.OnMeasure(widthMeasureSpec, expandSpec);
ViewGroup.LayoutParams layoutParams = LayoutParameters;
layoutParams.Height = MeasuredHeight;
}
else
{
base.OnMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
}
有没有办法将MVXBindableListView的高度设置为列表的完整大小,这样它们就不会滚动,我可以使用ScollView?我尝试了,它将列表的高度设置为1个列表项的高度。。。列表仍然可以滚动…:(你必须使用MvxBindableLinearLayout来完成此操作,其高度设置为包裹内容-请参阅其他提到LinearLayout类似的问题,谢谢你Stuart,MvxBindableLinearLayout确实做到了!我遵循了你在上一篇评论中发布的链接,现在一切都很完美!)有没有办法将MVXBindableListView的高度设置为列表的完整大小,这样它们就不会滚动,我可以使用ScollView?我尝试了,它将列表的高度设置为1个列表项的高度。。。列表仍然可以滚动…:(你必须使用MvxBindableLinearLayout,其高度设置为包裹内容-参见其他提到LinearLayout的问题,谢谢你Stuart,MvxBindableLinearLayout确实做到了!我遵循了你在之前评论中发布的链接,现在一切都很好!:)谢谢你Alexey,但我最终使用了斯图尔特的方法……;)谢谢你,阿列克西,但我最终还是用了斯图尔特的方法……;)